locked
Event handler for right-click action.

    Question

  • Hi,

    I'm trying to add an event handler when right-clicking an item. If I right click an item it's marked as selected no event seems to be triggered. 
    It also would be great to know if there's a event triggered when you right click on the background to show the appbar (when it's set to sticky=false).

    Which event is triggered when right-clicking?.

    Thanks.
    Diego.

    Wednesday, May 23, 2012 1:33 PM

All replies

  • Hi Diego,

    What are you going to do with the right click out of curiosity?  How will this work in a touch only environment?

    You can trap the mouse events.  The event object will tell you what button is used (1 is left, 2 is right, 4 is center).

    -Jeff


    Jeff Sanders (MSFT)

    Wednesday, May 23, 2012 8:39 PM
    Moderator
  • Hi Jeff,

    Thanks for replying. In a touch only environment I won't have that situation but I do in a mouse environment. I have a "select mode" for items that lets me select some of them. When I left-click an item I'm capturing the onItemInvoke event (for the listview) and based on which mode I am I display some information about it (view mode) or mark it as selected (select mode) and do some other stuff.
    The issue is that if I right click any item the onItemInvoke event is not triggered but the framework is marking it as selected, dus leading to un inconsistent state. 

    Which event should I use to trap the right click?. Can I set it thru WinJS.UI.setOptions for the listview or do I have to set a particular event (ie. click) on every item?.

    Thanks.

    Thursday, May 24, 2012 2:54 PM
  • I see, that is going to be awkward.  How about if you just turn off the select instead of trying to override the right mouse click?  What is the control you are looking at?

    -Jeff


    Jeff Sanders (MSFT)

    Thursday, May 24, 2012 5:24 PM
    Moderator
  • What do you mean by turning off select?. I need items to be eligible for selection. I want to accomplish exactly the same thing the Store app does with updates, where you can select (with left or right clicks) which updates you want to install and app bar buttons are enabled/disabled accordingly.

    Thanks.
    Diego.

    Thursday, May 24, 2012 6:17 PM
  • I would highly discourage changing the default behavior.  Customers will expect your app to behave like every other application and you would break that with your change.

    Perhaps we should work on the main issue instead?


    Jeff Sanders (MSFT)

    Thursday, May 24, 2012 7:14 PM
    Moderator
  • Hi Jeff,
    Sorry for replying late to this. Ok, so you mean that the default behaviour when right clicking a list item is to do nothing?. I've seen in the Store app that updates are handled the way I would like to do in my app. You can select which updates to install (with left or right clicks) and app bar buttons are displayed accordingly (e.g. when there's no item selected the Install button is disabled and that can be triggered by both left and right clicking the item which is what I would like to accomplish).

    Thanks.
    Diego.

    Thursday, June 21, 2012 3:44 PM
  • Well, 

    Fortunately the customer changed their mind and I'm using the listview with tapBehavior = invokeOnly and selectionMode = multi so when I left click an item the invokeOnly binded method is fired and when I right click the selectionChanged event handler is fired. It's a little awkward to handle clicks that way (would prefer to have the button index like the MSPointerXXX event object has) but that method did the trick for me. 

    Thanks.

    Monday, July 09, 2012 7:51 PM