The Palm OS’s display system had to undergo three mayor overhauls in the last few years – dynamic UI(long time ago), HiRes+ and 5way navigation. The path to dynamic UI was very, very buggy afaik, HiRes+ worked well and 5way nav is, umm, more like dynamic UI to me.

Anyways, I had a nice modal form that reacted to WinDisplayChangedEvents. That form was popped up via FrmPopupForm(the only such form in the entire app…all others worked fine =) ). The resizing didn’t quite work out on Chris Schrinner’s TX:
a Fixing 5way navigation distortion   or   how to prevent the blue ring from fuxating your modal form
b Fixing 5way navigation distortion   or   how to prevent the blue ring from fuxating your modal form

There seems to be some kind of quirk with PalmOne engineers having placed a cache into their 5way nav system that stores whats behind the blue ring. Now, when the form gets resized, this cache somehow screws up and distorts/obfuscates the proximity of the poor control that happened to be selected.

Fixing the problem is rather simple – remove the focus, do the movement and then restore focus. Here is how I did it(no special headers needed btw):

UInt32 buffer;
Err err;
err = FtrGet(sysFtrCreator, sysFtrNumFiveWayNavVersion, &buffer);
if (err == errNone)
{
// One-handed navigation is supported
buffer=FrmGetFocus(pForm);
FrmSetFocus(pForm,noFocus);
FrmNavRemoveFocusRing (pForm);
}

//Party with the controls here

if(err==errNone && buffer!=noFocus)
{
FrmSetFocus(pForm,buffer);
}
FrmDrawForm(pForm);

P.s. I know that this code doesn’t detect the Treo 600 as 5way capable. But since the Treo 600 has no HiRes+ screen, I don’t really care as it will never see this code anyways….

Related posts:

  1. A funny onehand navigation quirk – controls getting skipped
  2. Identifiying a 5way navigator reliably
  3. Invalid Insertion Point Position via FldSetFocus – what to do
  4. Why the Treo form factor can’t really be changed
  5. On inserting DRM/error catch&terminate code early

3 Responses to “Fixing 5way navigation distortion – or – how to prevent the blue ring from fuxating your modal form”

  1. This is documented by Palm in their SDK.
    From the Palm Developer Guide in SDk-5.3 section 9.9.9.3:
    ——————————————–
    9.9.9.3 Focus rings and redraw problems

    An application may run into redraw problems when it controls the drawing and/
    or removal of focus rings (when they directly call HsNavDrawFocusRing() and/or
    HsNavRemoveFocusRing()).
    Drawing focus rings around an object and properly restoring an object when it
    loses the focus ring is very tricky. The rings can be drawn over an object’s frame,
    over another object, and over pixels directly drawn to the screen. When the
    system draws and removes the ring, it takes these possibilities into account and
    also contends with clipping rectangles and objects that change appearance
    between receiving and losing the focus ring. The system manages these
    complications fairly well when it is controlling the drawing and removal of rings.
    For an application to properly handle these complications, developers should
    have a basic understanding of the ring drawing and removal mechanism. Before
    a ring is drawn, the bits behind the ring are saved. When a ring is removed, the
    bits behind the ring are restored, the object is redrawn, and the portion of any
    object that was behind the ring is redrawn.
    Therefore, it is important that an application always draw an object in its normal
    state before drawing a focus ring around it. If the appearance of an object with the
    focus ring needs to change (that is, if an object’s bounds needs to change) or if
    what’s behind the focus ring needs to change (for example, if the background
    color of the form needs to change), an application should remove the ring, make
    the changes, draw the changes, and then draw the ring again.
    ———————————————-

  2. Hi,
    a little hint for the OnBoardC afficionados.

    pasting as FrmDrawForm below the FrmNavRemoveFocusRing (pForm);

    makes the code work in OBC too – at least it did for Daily Quote!

    Best regards
    Tam Hanna

  3. Thanks.This tips are great.

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting

© 2013 TamsPalm - the Palm OS / web OS Blog Suffusion theme by Sayontan Sinha