You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I feel the way that an action is found for a @click link is unintuitive. Consider this code:
fromtextual.appimportApp, ComposeResultfromtextual.containersimportVerticalfromtextual.screenimportScreenfromtextual.widgetsimportLabelclassClickLabel(Label):
defaction_click(self) ->None:
self.notify("ClickLabel.action_click reporting in!")
classClicker(Vertical):
defcompose(self) ->ComposeResult:
yieldLabel("1: [@click=app.click]Click on this for an app action to fire[/]")
yieldLabel("2: [@click=screen.click]Click on this for a screen action to fire[/]")
yieldLabel("3: [@click=click]Click on this for this container's action to fire[/]")
yieldClickLabel("4: [@click=click]Click on this for the custom widget's action to fire[/]")
defaction_click(self) ->None:
self.notify("Clicker.action_click reporting in!")
classMainScreen(Screen):
defcompose(self) ->ComposeResult:
yieldClicker()
defaction_click(self) ->None:
self.notify("Screen.action_click reporting in!")
classClickBaitApp(App[None]):
defon_mount(self) ->None:
self.push_screen(MainScreen())
defaction_click(self) ->None:
self.notify("App.action_click reporting in!")
if__name__=="__main__":
ClickBaitApp().run()
Here's what happens when you click on each of those links:
The App-level action is fired. This is expected.
The screen-level action is fired. This is expected.
The App-level action is fired; this is (I think) unexpected.
The widget-level action is fired; this is expected.
I feel the way that situation 3 is handled is unintuitive. Surely it would make more sense to have actions that handle clicks looked for going up the DOM? Or if not that, how would we at least introduce a parent namespace too? I feel it's obvious an intuitive that someone would want to compose a collection of widgets into a container and have @click links in the child widgets handled by an action on the container.
The text was updated successfully, but these errors were encountered:
I feel the way that an action is found for a
@click
link is unintuitive. Consider this code:Here's what happens when you click on each of those links:
I feel the way that situation 3 is handled is unintuitive. Surely it would make more sense to have actions that handle clicks looked for going up the DOM? Or if not that, how would we at least introduce a
parent
namespace too? I feel it's obvious an intuitive that someone would want to compose a collection of widgets into a container and have@click
links in the child widgets handled by an action on the container.The text was updated successfully, but these errors were encountered: