Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Sat Oct 20, 2018 11:38 pm

All times are UTC - 7 hours

Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Nov 18, 2011 12:31 pm 

Joined: Thu Aug 09, 2007 4:44 pm
Posts: 67
I have several ButtonV2 objects on a G55 screen. the # of objects varies with user input, as does their position on the screen. Often I will put focus on an object, which allows me to enter a mode where I change its position on the screen. At times I will move an object to part of the screen and once I move focus off this object I can not navigate back to it via the direction pad (up/down, left/right), and since I don't have a touchscreen on the G55 there is no way for me to access this object again.

This is unacceptable, so I need to figure out a workaround to whatever the rules are that Qlarity uses to focus on an object.

Any help is greatly appreciated.



PostPosted: Fri Nov 18, 2011 4:39 pm 

Joined: Thu Aug 09, 2007 4:44 pm
Posts: 67
Can anyone explain the rules that the QSI interfaces use to pick which object is focused on next when an arrow key is pressed?


PostPosted: Mon Nov 21, 2011 7:12 am 
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
The direction focus behavior is quite complex. Basically when you press an arrow button to change focus, the G55 calculates the distance and direction to all other eligible objects (essentially enabled and focusable) and attempts to move the focus to the nearest object that is most in the direction you pressed.

I will freely admit that the algorithm has issues. It works best when the objects tend to be similar sized (very long rectangles tend to give it some problems). It also works better when objects tend to be in a grid pattern.

The easiest way to nudge the problem is adjust the layout of screen somewhat. If that doesn't work there are a few other things that can be done.

The next easiest thing to do, if you have specific screens that have focus traversal issues is to add a hotkey object to those screens which handles the arrow keys. Here is an example
init parent := splashscreen

func ProcessBid(KeyASCII as unibyte, KeyString as charstr, BidType as integer) returns boolean
    return (KeyAscii == Key_UpArrow) or (KeyAscii == Key_DownArrow) or (KeyAscii == Key_LeftArrow) or (KeyAscii == Key_RightArrow)

func handleKeyDown()
    dim keyAscii as unibyte
    dim mods as unibyte
    dim kpd as boolean
    dim strg as charstr
    dim fobj as objref
    dim idx as integer

    dim btn1Focus[] as objref
    init btn1Focus := [Button_2, Button_3, Button_2, Button_3]
    dim btn2Focus[] as objref
    init btn2Focus := [Button_1, Button_3, Button_1, Button_3]
    dim btn3Focus[] as objref
    init btn3Focus := [Button_2, Button_1, Button_2, Button_1]
    dim fArr[] as objref

    GetKeyCodeInfo(keyAscii, mods, kpd, strg)
    if keyAscii == Key_UpArrow then
        idx = 0
    elseif keyAscii == Key_DownArrow then
        idx = 1
    elseif keyAscii == Key_LeftArrow then
        idx = 2
    elseif keyAscii == Key_RightArrow then
        idx = 3

    fobj = _GetFocusObj()
    if fobj == button_1 then
        fArr = btn1Focus
    elseif fobj == button_2 then
        fArr = btn2Focus
    elseif fobj == button_3 then
        fArr = btn3Focus

    _print("Setting Focus to: " + str(farr[idx]))

init handleallkeys := true
init mypriority := _Focus_Priority

Finally, if you want to actually modify the focus algorithm yourself, you are welcome to, although the code is a bit opaque. To do so, do the following:

Edit->Add/Edit Templates->New Template->Copy the code of an existing template in a library->Based On=KeyTranslationV2.

This will bring the focus code (and some additional code that isn't important to this discussion) directly into your workspace to edit. The function you are interested in modifying is the global function called _keySetupDirFocusChange. You can ignore the rest of the code that is imported to your workspace once you do this. (Note: If you change your mind it can be a bit tricky to back the imported code back out of the workspace so you may want to backup your workspace before you import).


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group