Forget me for being such a noob on ReAction matters. But how on earth do you know when the user aborts the popupmenu without selecting an item? Apparently the MenuHandlerFunc is not called and I don't know enough about boopsi matters to figure out how to know such things otherwise.
Fri, 2014-06-06 22:17#1
How to know when an popupmenu is aborted?
Hi, I use popupmenu(item).class in KeymapSwitcher and here is piece of code to "control" items:
When no option is choosed I simple 'DisposeObject()', if an item is choosed it goes thru 'switch(item_ID)' code and ends (again to 'DisposeObject()').
Ok, I must have confused another problem with the one I was having, as my code looks pretty much exactly like yours. For some reason, I must have believed, that the call to IDoMethod was asynchronous and thus was commited to the additional belief, that I needed a signal from the MenuHandlerFunc to get what I wanted. Although, if you actually need to know, if the user aborts, then I don't see any way to get that information. Which is perhaps.... strange...
Didn't try, but myabe if you set a variable to return 0xFF (or whatever you want) in case no itemID matches or something alike then you'll know it popupmenu was "aborted/cancelled" or "used".
You can check the result of the IDoMethod call, like described in the popupmenu autodocs.
It is returning NULL, if the user did not select anything (which means that the popupmenu was aborted). Oterhwise it will return the popupmenuitem object.
uint32 result = IDoMethodA(APTR obj, struct pmOpen *msg);
This method is used to open a popup menu.
obj - popupmenu object pointer
msg - pointer to fully initialized struct pmOpen
The popupmenuitem object selected by the user or NULL
for nothing selected.
Off course the MenuHandlerFunc is not called, if the selection was aborted. So it is all pretty straight forward.