KeyDown and Focus

  1. 7 weeks ago

    Canvas with a big image is used in a window, the image is scrolling either with the mouseWheel or with the cursors. This works ok.
    A listbox is in the same window, when clicked to select a line the focus goes to the listbox and then the key for scrolling don't work anymore until you click on the canvas again to set the focus there.
    I added in the keyDown event in the listbox

    canvas1.setFocus

    This works ok, but the first keydown is lost.
    In fact the window has several lists and I would like that the keyDown events are always processed by the canvas.
    Is there a way? Sure it should be, but I cannot found right now.

  2. I found that using

    Canvas1.SetFocus

    in the

    GotFocus event

    of any object that may have focus, then it works. I do not know if there is a better solution.

  3. Norman P

    Dec 11 Pre-Release Testers, Xojo Pro outside

    does your canvas have accept focus (or whatever it was they renamed it to for API 2.0) enabled ?

  4. yes, "allow focus"= true

  5. Norman P

    Dec 11 Pre-Release Testers, Xojo Pro outside

    had to reread your original post

    IF you click the listbox to give it focus then it WILL also take over the handling of keys - thats the point of it having focus
    Which make sense since it now has focus and there are things it does in response to a key press

    IF you want to do something else you dont really have a choice but to implement Keydown (and maybe Keyup) in the listbox and do "something else" like you have

    Personally if I have a control like a listbox with focus and I press arrow down I would be kind of surprised if something else scrolled
    It would not be intuitive

  6. Well in my app the expected fact is that always the keys scroll the image.

    Using the procedure I posted (GotFocus event ) it works ok now.

or Sign Up to reply!