Jump to content

TUniTreeMenu - OnClick event should be handed the clicked node


wprins

Recommended Posts

I'm trying to make the menu respond when an item is clicked repeatedly (to implement collaps/expand by setting the Micro property), but it seems I have no way of implementing this that I can see because the click even doesn't seem to know which item's been clicked?  That is to say, the Sender parameter that is passed to the event is the entire menu itself.  It would seem to have made more sense to pass the clicked item than (as currently) the entire menu object itself?  Am I missing something?

Moreover OnSelectionChange is also not passed the selected node, nor is menu.Selected set to the (newly) selected node when the event handler is called.  

How are you meant to respond to repeated clicks on menu items in this menu object? :wacko2:

Link to comment
Share on other sites

I have since realised that you can accomplish this indirectly be segregating the menu items into a TUniMenuItems, since the TUniMenuItems do provide the clicked item to OnClick handlers related to the menu items etc.  (One could also use a corresponding TActionList to attach to TUniMenuITems if desired, though notably if you want to use the click handler for a menu item, then you must not use a TAction for this menu item since this will stop the TUniMeniItems OnClick from triggering.)

It should be noted that when doing this the existing Items become effectively redundant, hence I'd argue that either using a TUniMenuItems ought to be the only way to supply menu items to this control, or if the current Items property is retained (for developers who do not want to use TUniMenuItems), then it ought to be possible to recognized clicked items as previously described. 

Link to comment
Share on other sites

×
×
  • Create New...