However regardless of the function signature of MyState.menu_click (unless there are no args), I get the following:
ValueError: number of arguments in MyState.menu_click doesn't match the definition of the event trigger 'rs = triggers.get(self._get_event_trigger_key(), lambda: [])' defined in the 'DropdownButton' component
I would ultimately like to pass info of the clicked menu item into the MyState.menu_click function. The demo on the official antd docs simply pass the event along, though it seems you may have access to key and keyPath.
Since the dropdown button menu seems to mirror the antd menu component, I took a look at how that was wrapped as well. Mirroring that a bit to modify the dropdown button wrapper class, I seemed to get it to work, and updated MyState.menu_click to accept key, key_path args.
class OnSelectEvent(Base):
item: Any
key: Any
keyPath: Any
selectedKeys: List[str]
class DropdownButton(Dropdown):
...
def get_event_triggers(self) -> Dict[str, Any]:
_triggers = super().get_event_triggers()
def _menu_on_click(ev: OnSelectEvent):
return [ev.key, ev.keyPath]
_triggers.update({
EventTriggers.ON_CLICK: lambda: [],
'menu.on_click': _menu_on_click,
})
return _triggers
Is this the right way to solve this and it simply hasn't been implemented yet, or am I missing something?
I am trying to get the menu of the dropdown button to call an event function but am running into argument errors.
However regardless of the function signature of MyState.menu_click (unless there are no args), I get the following:
ValueError: number of arguments in MyState.menu_click doesn't match the definition of the event trigger 'rs = triggers.get(self._get_event_trigger_key(), lambda: [])' defined in the 'DropdownButton' component
I would ultimately like to pass info of the clicked menu item into the MyState.menu_click function. The demo on the official antd docs simply pass the event along, though it seems you may have access to key and keyPath.
Since the dropdown button menu seems to mirror the antd menu component, I took a look at how that was wrapped as well. Mirroring that a bit to modify the dropdown button wrapper class, I seemed to get it to work, and updated MyState.menu_click to accept key, key_path args.
Is this the right way to solve this and it simply hasn't been implemented yet, or am I missing something?