02-05-2014 10:54 AM
I have added a context menu to a button. The problem is the buttons still gets clicked even if the context menu is open. Since my button opens a new page, this would be confusing.
How can I prevent the button being clicked when the context menu is visible?
Solved! Go to Solution.
02-05-2014 11:09 AM - edited 02-05-2014 11:13 AM
The simplest way is to set a boolean flag within the visualStateChanged() slot that is read by your buttons onClicked() slot and acted on accordingly...
Having said that changing a button's default action to one that invokes a Context Menu is the kind of UI change that will confuse a user and you are better off sticking to the UI guidelines.
How does the user know to long hold your button?
02-05-2014 11:48 AM - edited 02-05-2014 11:49 AM
I'm not trying to tell you what to do it's totally up to you of course.
The difference with a ListView item is that there is no other way to access options for that item and it is documented and expected behaviour it isn't for a Button.
I'm just saying you should think a little about the user experience. What tells the user that long holding a Button brings up a Context menu when nearly every other app they will have used will not have the same action?
I'm not saying there aren't arguments for use cases for doing this but in general a Button is a click and forget action only.
Also does every Button in your app now behave the same way, if not why not?
These are questions that will be going through you app user's minds.
The beauty of development is that there are always different ways to do things and still stay within the UI guidelines.