Josh Posted March 6, 2023 Share Posted March 6, 2023 In the current build of 1.0.2 menu events emit events with the top-most menu as the event source and the actual menu item is stored in event.extra. This is similar to the way treeview nodes work. With this approach, it is only necessary to listen for events from the main menu widget, instead of adding a listener for every single menu item created. In practice I found myself adding a lot of listeners that evaluated ALL events, rather than adding a listener for each menu item. This is bad because it each one of those functions is being called every single time any event occurs, even a mouse move event. Listeners themselves are very efficient when they are created with a specific widget, but they are less efficient if the widget parameter is NULL and event is none because they get called for every single event that occurs, and thousands of mouse events are constantly occurring. As an application scales I find it is best to rely on a smaller number of listeners, and when hundreds of widgets are involved, they can be packed into a single root. Treeviews work like this, then menus do now too, and the property grid is a good example of this. This allows you to have hundreds of widgets with only a few listeners. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted March 6, 2023 Share Posted March 6, 2023 1 hour ago, Josh said: In practice I found myself adding a lot of listeners that evaluated ALL events, This is what I'm doing at the moment too... I do it to set individual custom widget members like; left_pressed = true; mouse_over = true; etc. I did it because I wanted to know if the mouse was over a panel which was full of buttons or other widgets and I had to setup a recursive function that sent the event_id up the chain to a widgets parent. So are you saying the events work in reverse now? They go down from the root widget down to all the respective children? Quote Link to comment Share on other sites More sharing options...
Josh Posted March 7, 2023 Author Share Posted March 7, 2023 No, I am saying that for menus the top-most menu will be the event source, and the individual menu that triggered the event will be stored in event.extra. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted March 7, 2023 Author Share Posted March 7, 2023 Usually I just get the menu text and evaluate actions based on that, rather than storing a bunch of variables with the individual menu items. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.