Receiving events in Drawing Area - Motif

This is a discussion on Receiving events in Drawing Area - Motif ; I would like to track the state of the shift key while the pointer is in a drawing area, so that I can display a different cursor and respond to clicks differently when shift is down. The enclosing shell widget ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Receiving events in Drawing Area

  1. Receiving events in Drawing Area

    I would like to track the state of the shift key while the pointer is in a
    drawing area, so that I can display a different cursor and respond to clicks
    differently when shift is down. The enclosing shell widget of the drawing
    area has a XmPOINTER focus policy, so keyboard focus tracks the pointer.
    While the pointer is in the drawing area, it is easy enough to catch key
    up/down events in the input callback to track the shift key state. My
    problem occurs when the pointer is outside the drawing area. The shift key
    state can change without the app knowing about it. When the pointer does
    enter the drawing area, the app does not know what the shift key state is.

    It seems like I want the drawing area to catch KeymapNotify events, so that
    it can determine the state of the shift key when it gains focus. However, I
    haven't figured out how to do this. In fact, I haven't even been able to
    get my input callback to receive FocusIn or EnterNotify events, even though
    I've added what I think are appropriate lines to the drawing area
    translation table. Is there a simple way to do what I want?

    Thanks for any help,
    Brian




  2. Re: Receiving events in Drawing Area

    Brian Mirtich wrote:
    > I would like to track the state of the shift key while the pointer is in a
    > drawing area, so that I can display a different cursor and respond to clicks
    > differently when shift is down. The enclosing shell widget of the drawing
    > area has a XmPOINTER focus policy, so keyboard focus tracks the pointer.
    > While the pointer is in the drawing area, it is easy enough to catch key
    > up/down events in the input callback to track the shift key state. My
    > problem occurs when the pointer is outside the drawing area. The shift key
    > state can change without the app knowing about it. When the pointer does
    > enter the drawing area, the app does not know what the shift key state is.
    >
    > It seems like I want the drawing area to catch KeymapNotify events, so that
    > it can determine the state of the shift key when it gains focus. However, I
    > haven't figured out how to do this. In fact, I haven't even been able to
    > get my input callback to receive FocusIn or EnterNotify events, even though
    > I've added what I think are appropriate lines to the drawing area
    > translation table. Is there a simple way to do what I want?
    >
    > Thanks for any help,
    > Brian
    >
    >
    >

    "XQueryPointer returns the current logical state of the keyboard buttons
    and the modifier keys..."

    HTH,
    --
    Michel Bardiaux
    Peaktime Belgium S.A. Bd. du Souverain, 191 B-1160 Bruxelles
    Tel : +32 2 790.29.41


  3. Re: Receiving events in Drawing Area



    Brian Mirtich wrote:
    >
    > I would like to track the state of the shift key while the pointer is in a
    > drawing area, so that I can display a different cursor and respond to clicks
    > differently when shift is down. The enclosing shell widget of the drawing
    > area has a XmPOINTER focus policy, so keyboard focus tracks the pointer.
    > While the pointer is in the drawing area, it is easy enough to catch key
    > up/down events in the input callback to track the shift key state. My
    > problem occurs when the pointer is outside the drawing area. The shift key
    > state can change without the app knowing about it. When the pointer does
    > enter the drawing area, the app does not know what the shift key state is.
    >
    > It seems like I want the drawing area to catch KeymapNotify events, so that
    > it can determine the state of the shift key when it gains focus. However, I
    > haven't figured out how to do this. In fact, I haven't even been able to
    > get my input callback to receive FocusIn or EnterNotify events, even though
    > I've added what I think are appropriate lines to the drawing area
    > translation table. Is there a simple way to do what I want?
    >
    > Thanks for any help,
    > Brian


    AS Mr. Bardiaux pointed out, XQueryPointer can be used to get the state
    variable. However, if you can't determine when you need to call this
    (you said you could not get enter notify events, etc.), this does not
    help.

    For a DrawingArea widget, you probably should not try to override the
    motion translations, as this will break the ability of the DrawingArea
    to properly handle events and pass them, on to any gadgets or widgets in
    the drawing area. Instead, try adding an event handler
    (XtAddEventHandler) for PointerMotionMask, or some combination of
    PointerMotionMask, EnterWindowMask, LeaveWindowMask, and
    FocusChangeMask.
    --
    Fred L. Kleinschmidt
    Boeing Associate Technical Fellow
    Technical Architect, Common User Interface Services
    M/S 2R-94 (206)544-5225

+ Reply to Thread