Search Unity

how to get mouse click position when got ContextualMenuPopulateEvent.

Discussion in 'UIElements' started by wang37921, Jan 17, 2019.

  1. wang37921

    wang37921

    Joined:
    Aug 1, 2014
    Posts:
    58
    ContextualMenuPopulateEvent.localMousePosition is zero.
    any other method?
     
  2. wang37921

    wang37921

    Joined:
    Aug 1, 2014
    Posts:
    58
    o_O i access it in menu.AppendAction's callback. its information is clear before be pooled?
     
    Last edited: Jan 17, 2019
  3. etienne_phil_unity

    etienne_phil_unity

    Unity Technologies

    Joined:
    Jan 15, 2019
    Posts:
    15
  4. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    522
    ContextualMenuPopulateEvent.localMousePosition still seems to return zero. Is there a workaround for this?
     
  5. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    522
    Bump ...

    originalMousePosition and mousePosition is also zero. Basically, I am creating a node from context menu and I need to place it where I opened context menu. Unity 2019.3.0b1.
     
  6. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    226
    (not tested, just an idea) Maybe try using a MouseDownEvent in addition to the ContextualMenu event. You can register for both and save the mouse position from the MouseDownEvent for future use by your Context.. event handler.
     
  7. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    522
    Thanks @uDamian that's a functioning work-around while I wait for a fix.