Events need to play nice with widgets

Creating a widget always messes up my events. Sometimes, events get propagated to the parent element (I understand why this happens, thanks to @fizfaz’s explanation. I can live with it, although it is somewhat unexpected and feels broken) but more importantly, events just get wildly mixed up. It’s like somehow events get attached to completely different widgets. Even direct siblings end up with events that have no discernible order or origin.
I am now employing a workaround whereby I create an empty widget shell and then drag all the nested cells into it after the fact. But even so, the mixing up of events still happens and I have not found a workaround. I’ll keep an eye on this though and if I find out if there is an underlying principle I will supply a test file.

I think I have nailed the bugger. I still had the original file so hopefully this helps debugging the issue.

Swapped Widgets.zip (7.2 MB)

Due to our way we handle events in widgets vs. basic cells I do not think we can handle it all automatically in a single “Create Widget”-action. Maybe a “create wrapper”-widget action (creating a widget out of a cell, makes the top-level-cell have “individual content” and just move the content in the wrapper) … might help here. Or storing event-handlers not only on top-level of the widget-cell, but this would open another can of worms … :slight_smile:

But why is that? I have now reordered all the events manually and it works like it did before. The objects are all individual widgets and hence have their own events.

yes, but since we only allow events defined “globally” for the widget (and not inside some of its cells), the step to create the widget has to change the behavior. We could either remove the events, or (as we do know) move them up the newly create widget instance cell (which is far from perfect). I am not sure if this is understandable :slight_smile: . Therefor I only see the two possibilities I mentioned before.

Ah, could it be because I had forgotten to switch the the OS Container widget’s content to ‘individual’? That would make sense. No, it is not understandable. At least not until you have fallen on your face a few times with it :joy: