drawing Area and keyboard events - Motif

This is a discussion on drawing Area and keyboard events - Motif ; I'm trying to get events from keyboard on DrawingArea widget. drawingArea has children which have property XmNTraversalOn with value "FALSE". When I first load the drawing area everything works fine and drawingArea catch the key events. But after switching between ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: drawing Area and keyboard events

  1. drawing Area and keyboard events

    I'm trying to get events from keyboard on DrawingArea widget.
    drawingArea has children which have property XmNTraversalOn with value
    "FALSE". When I first load the drawing area everything works fine and
    drawingArea catch the key events. But after switching between
    translation tables (to another translation table with no key events
    and back to the former translation with key events), the drawingArea
    stop reacting to key events. I think the reason is the drawing Area
    children, though they are defined to be untraversable.

    Any Ideas?

  2. Re: drawing Area and keyboard events

    sarah wrote:
    > Any Ideas?

    1) Don't switch translation tables, use "if" in your keyboard related
    callbacks.
    2) Use
    XmProcessTraversal(yourDrawingAreaWidget, XmTRAVERSE_CURRENT);
    to ensure the keyboard focus on the widget you want.

    Dušan Peterc
    http://www.arahne.si

  3. Re: drawing Area and keyboard events

    On 17 מרץ, 21:41, arahne wrote:
    > sarah wrote:
    > > Any Ideas?

    >
    > 1) Don't switch translation tables, use "if" in your keyboard related
    > callbacks.


    I must switch between translation tables. What do you mean use "if"?
    when clicking a certain button the event has to react in a
    different way so translation table for drawingArea is changed using
    XtVaSetValues.
    Later on I change translation Table again in order to get back to
    former behaviour. How can i not switch between the translation
    tables????

    > 2) Use
    > XmProcessTraversal(yourDrawingAreaWidget, XmTRAVERSE_CURRENT);
    > to ensure the keyboard focus on the widget you want.


    I did that already

    > Dušan Peterchttp://www.arahne.si


    Thanks for the help I will be happy to get more advices

  4. Re: drawing Area and keyboard events

    sarah wrote:
    > I must switch between translation tables. What do you mean use "if"?
    > when clicking a certain button the event has to react in a
    > different way so translation table for drawingArea is changed using
    > XtVaSetValues.
    > Later on I change translation Table again in order to get back to
    > former behaviour. How can i not switch between the translation
    > tables????

    Sorry for being so terse.
    In the software I write, I use small number of callbacks for
    different types of keyboard (or mouse) handling events.
    The callbacks examines widget ID and calls different functions
    for different keystrokes depending on widget ID.
    If the program has states (some functions are only possible
    in certain state, or different actions need to be called in
    a different state), then the actual function being called
    is evaluated based on program state with "if" or "case"
    statement. So I do not need to switch translation tables.

    But I agree that your approach with switching translation
    tables should also work. If you can provide a small test
    case which demonstrates the issue, I can try it.

    Best regards,

    Dušan Peterc
    http://www.arahne.si

  5. Re: drawing Area and keyboard events

    On 22 מרץ, 00:37, arahne wrote:
    > Sorry for being so terse.
    > In the software I write, I use small number of callbacks for
    > different types of keyboard (or mouse) handling events.
    > The callbacks examines widget ID and calls different functions
    > for different keystrokes depending on widget ID.
    > If the program has states (some functions are only possible
    > in certain state, or different actions need to be called in
    > a different state), then the actual function being called
    > is evaluated based on program state with "if" or "case"
    > statement. So I do not need to switch translation tables.
    >

    I'm working with an already exisitng code so I can't start from
    scratch and do whatever I like. That's my problem.

    > But I agree that your approach with switching translation
    > tables should also work. If you can provide a small test
    > case which demonstrates the issue, I can try it.
    >

    A small test case which I wrote just for a check was working fine.
    The regular program is to big and complicated to be displayed here.

    I just wanted to get ideas for what can happen whilst switching
    translation tables that avoid drawingArea from fetching the key events
    as it did in the first place.
    I tried to check if any widget on drawingArea became (TraversalOn,
    TRUE) during the switching tabel process but couldn't find anything of
    that kind.
    So what else can it be?

    Best regards,
    and Thanks for help
    Sarah


  6. Re: drawing Area and keyboard events

    sarah wrote:
    > On 22 מרץ, 00:37, arahne wrote:
    >> Sorry for being so terse.
    >> In the software I write, I use small number of callbacks for
    >> different types of keyboard (or mouse) handling events.
    >> The callbacks examines widget ID and calls different functions
    >> for different keystrokes depending on widget ID.
    >> If the program has states (some functions are only possible
    >> in certain state, or different actions need to be called in
    >> a different state), then the actual function being called
    >> is evaluated based on program state with "if" or "case"
    >> statement. So I do not need to switch translation tables.
    >>

    > I'm working with an already exisitng code so I can't start from
    > scratch and do whatever I like. That's my problem.
    >
    >> But I agree that your approach with switching translation
    >> tables should also work. If you can provide a small test
    >> case which demonstrates the issue, I can try it.
    >>

    > A small test case which I wrote just for a check was working fine.
    > The regular program is to big and complicated to be displayed here.


    You should be able to reproduce the problem on a
    smaller scale, otherwise is possible that the reason
    lies elsewhere.
    Sometimes small memory overwrites (one or two bytes)
    can cause slight erratic behavior in a large application,
    instead of a crash.
    You can try to test your application with Valgrind.
    http://valgrind.org/

    > I just wanted to get ideas for what can happen whilst switching
    > translation tables that avoid drawingArea from fetching the key events
    > as it did in the first place.

    The only "problem" I had with keyboard accelerators
    on drawing area widget was, when I use them in scrolled
    window, and scrollbars also get the keyboard focus.
    So I needed to apply my changes to callbacks also on scrollbars.

    Sorry that I can't be of more help,

    Dušan Peterc
    http://www.arahne.si

+ Reply to Thread