Added IconsHelper and updated Keyboard to support require_inside flag
This commit is contained in:
@@ -17,12 +17,16 @@ class Keyboard(MultipleInstance):
|
||||
super().__init__(parent, _id=_id)
|
||||
self.combinations = combinations or {}
|
||||
|
||||
def add(self, sequence: str, command: Command):
|
||||
self.combinations[sequence] = command
|
||||
def add(self, sequence: str, command: Command, require_inside: bool = True):
|
||||
self.combinations[sequence] = {"command": command, "require_inside": require_inside}
|
||||
return self
|
||||
|
||||
|
||||
def render(self):
|
||||
str_combinations = {sequence: command.get_htmx_params() for sequence, command in self.combinations.items()}
|
||||
str_combinations = {}
|
||||
for sequence, value in self.combinations.items():
|
||||
params = value["command"].get_htmx_params()
|
||||
params["require_inside"] = value.get("require_inside", True)
|
||||
str_combinations[sequence] = params
|
||||
return Script(f"add_keyboard_support('{self._parent.get_id()}', '{json.dumps(str_combinations)}')")
|
||||
|
||||
def __ft__(self):
|
||||
|
||||
Reference in New Issue
Block a user