Re: up arrow and down arrow

new topic     » goto parent     » topic index » view thread      » older message » newer message

here is some code that seems to do the job.


-------------------------
include win32lib.ew
without warning

constant
    win = create(Window,"Up Down test",  0, 0, 0, 400, 400, 0),
    SB  = create(StatusBar, "", win, 0,  0, 0, 0, 0),
    fld1 = create(EditText, "", win, 5,  5, 200, 20, 0),
    fld2 = create(EditText, "", win, 5, 35, 200, 20, 0),
    fld3 = create(EditText, "", win, 5, 65, 200, 20, 0),
    tabseq = {fld1, fld2, fld3}

-- Used to remember where I was when the fld lost focus.
sequence fldposn
fldposn = {0, 0, 0}

procedure focus(integer self, integer event, sequence params)
    integer w

    w = find(self, tabseq)
    if w = 0 then
        return
    end if

    if event = w32HGotFocus then
        setIndex(self, fldposn[w])
    else
        fldposn[w] = getIndex(self)
    end if

end procedure

procedure movefocus(integer id, integer incr)
    integer w

    w = find(id, tabseq)
    if w = 0 then
        return
    end if

    w += incr
    if w > length(tabseq) then
        w = 1
    elsif w < 1 then
        w = length(tabseq)
    end if

    setFocus(tabseq[w])
end procedure

procedure keydown(integer self, integer event, sequence params)
    integer incr

    if params[1] = VK_DOWN then
        incr = 1
    elsif params[1] = VK_UP then
        incr = -1
    else
        return
    end if

    movefocus(self, incr)

end procedure

setHandler(tabseq, w32HKeyDown, routine_id("keydown"))
setHandler(tabseq, {w32HGotFocus,w32HLostFocus}, routine_id("focus"))

WinMain(win, Normal)

---------------------
Derek
----- Original Message -----
From: "George Walters" <gwalters at sc.rr.com>
To: "EUforum" <EUforum at topica.com>
Sent: Thursday, August 23, 2001 7:56 PM
Subject: Re: up arrow and down arrow


>
> Thanks Derek,
>
> Nice Idea but windows apparently ignores it. I even tried to set the
current
> field index to zero on a lostfocus event before the field is left.
>
> procedure lostFocusProcess()
>  setIndex(getSelf(),0)
> end procedure
>
> onLostFocus[Screen] = routine_id("processLostFocus")
> onKeyPress[Screen] = routine_id("keyPressProcessB")
> onKeyDown[Screen] = routine_id("keyPressProcessA")
>
> Windows 'remembers' where the cursor location was at the field (i.e. use
> your mouse and click it to the middle of a field) and if you return it
> places the cursor at that location (+- 1 based on up or down arrow being
> used) and ignores the setIndex().
>
> ...george
>
> ----- Original Message -----
> From: "Derek Parnell" <ddparnell at bigpond.com>
> To: "EUforum" <EUforum at topica.com>
> Sent: Wednesday, August 22, 2001 10:11 PM
> Subject: Re: up arrow and down arrow
>
>
> >
> > > From: George Walters <gwalters at sc.rr.com>
> > > To: EUforum <EUforum at topica.com>
> > > Reply-To: EUforum at topica.com
> > > Subject: Re: up arrow and down arrow
> > > Date: 23/08/2001 9:21:58 AM
> > >
> > >
> > > Thanks Derek,
> > >
> > >         I'm using the up and dn arrows to
> > > advance / backup editText fields
> > > (don't cringe too much) rather than what
> > > windows does (the same as left and
> > > right arrows). What windows does after I'm
> > > through with setFocus() is to
> > > move the arrow to an interior part (where
> > > it would have been on the previous
> > > field usually) of the editText field where
> > > I've setFocus(). Difficult to
> > > explain, hopefully you can follow.
> > >
> >
> > Just an idea, but try this ...
> >
> >   setFocus(nextFld)
> >   setIndex(nextFld, 0)
> >
> > this should tell windows where to place the cursor in the field you are
> > going to. The zero just means place it at the start of the field, but
you
> > can decide otherwise if you like.
> >
> > --------
> > Derek
> >
> >
> > confidential information intended solely for the use of the individual
or
> > entity to whom they are addressed. If you are not the intended recipient
> of
> > this message you are hereby notified that any use, dissemination,
> > distribution or reproduction of this message is prohibited. If you have
> > received this message in error please notify the sender immediately. Any
> > views expressed in this message are those of the individual sender and
may
> > not necessarily reflect the views of Global Technology Australasia
> Limited.
> >
> >
> >
> >
> >
>
>
>
>
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu