I need modifier key state in an event that doesn't provide access to it.

Discussion in 'Java' started by elrod@therod.org, Jan 9, 2006.

  1. Guest

    I have a JTree with a TreeSelectionListener to load a form when the
    node selection changes. I want to be able to perform a slightly
    different action when the selection changes while the CTRL key is
    pressed, but the TreeSelectionEvent does not provide access to the
    modifier key state.
    I am only necessarily interested in the modifier state if the selection
    changes by a mouse click, so I could use a MouseListener for this case
    if I could figure out a way to keep the TreeSelectionListener from also
    loading the form for this case (I have to keep the
    TreeSelectionListener method of switching forms for non-mouse-triggered
    changes), since both listeners will fire for a mouse selection change.

    So, in short, the ideal solution I seek is a way to know if the CTRL
    key is pressed from within the TreeSelectionListener, and if that is
    too impractical, then a way to keep the TreeSelectionListener from
    performing a form load if the MouseListener is going to handle it.
     
    , Jan 9, 2006
    #1
    1. Advertising

  2. Guest

    wrote:
    > I have a JTree with a TreeSelectionListener to load a form when the
    > node selection changes. I want to be able to perform a slightly
    > different action when the selection changes while the CTRL key is
    > pressed, but the TreeSelectionEvent does not provide access to the
    > modifier key state.
    > I am only necessarily interested in the modifier state if the selection
    > changes by a mouse click, so I could use a MouseListener for this case
    > if I could figure out a way to keep the TreeSelectionListener from also
    > loading the form for this case (I have to keep the
    > TreeSelectionListener method of switching forms for non-mouse-triggered
    > changes), since both listeners will fire for a mouse selection change.
    >
    > So, in short, the ideal solution I seek is a way to know if the CTRL
    > key is pressed from within the TreeSelectionListener, and if that is
    > too impractical, then a way to keep the TreeSelectionListener from
    > performing a form load if the MouseListener is going to handle it.


    Or, perhaps a simpler question to answer; where does a new MouseEvent
    originate? When it is generated, how is its 'modifiers' field
    populated? I tried to delve into the java source, but did not find an
    answer. I'm guessing (but hoping I am wrong) that the event is
    generated by system code, and as such, there is no accessible function
    for getting the modifiers.
     
    , Jan 9, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Ersatznom

    Need a new access modifier?

    John Ersatznom, Dec 27, 2006, in forum: Java
    Replies:
    17
    Views:
    574
  2. dost
    Replies:
    5
    Views:
    1,166
    Phlip
    Apr 28, 2006
  3. Richard Fairbanks
    Replies:
    0
    Views:
    105
    Richard Fairbanks
    May 3, 2010
  4. Replies:
    5
    Views:
    132
    -berlin.de
    Sep 5, 2006
  5. Ahmad
    Replies:
    2
    Views:
    77
    Paul Lalli
    Jan 2, 2008
Loading...

Share This Page