View previous topic :: View next topic |
Author |
Message |
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Tue Aug 27, 2002 12:07 am Post subject: Find which element has the FOCUS.... |
|
|
Here's a couple of examples to determine the focus.
This one seems to works pretty well for edit boxes.
It needs only one input char to determine focus.
Code: |
OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,Test Program,-1,0,200,100
DIALOG ADD,TEXT,T1,8,5,,,"E1"
DIALOG ADD,EDIT,E1,5,25,170,20
DIALOG ADD,TEXT,T2,33,5,,,"E2"
DIALOG ADD,EDIT,E2,30,25,170,20
DIALOG ADD,TEXT,T3,58,5,,,"E3"
DIALOG ADD,EDIT,E3,55,25,170,20
DIALOG ADD,STATUS,Stat
DIALOG SHOW
rem -- Get current text to compare --
%%old1 = @dlgtext(E1)
%%old2 = @dlgtext(E2)
%%old3 = @dlgtext(E3)
:EVLOOP
REPEAT
WAIT ".01"
if @not(@equal(%%old1, @dlgtext(E1)))
%%old1 = @dlgtext(E1)
DIALOG SET, Stat, "E1 has the focus..."
end
if @not(@equal(%%old2, @dlgtext(E2)))
%%old2 = @dlgtext(E2)
DIALOG SET, Stat, "E2 has the focus..."
end
if @not(@equal(%%old3, @dlgtext(E3)))
%%old3 = @dlgtext(E3)
DIALOG SET, Stat, "E3 has the focus..."
end
%e = @event()
UNTIL %e
goto %e
:CLOSE
EXIT
|
This one uses the DESIGN style which makes every event
a "CLICK" event, so it may not be very practical...
Code: |
rem -- VDS3 & VDS4 compatible --
OPTION SCALE, 96
Title By Mac
DIALOG CREATE,Design Style,-1,0,300,200,DESIGN
DIALOG ADD,BUTTON,B1,5,5,60,20
DIALOG ADD,TEXT,T1,8,70,,," Text Element "
DIALOG ADD,EDIT,E1,30,5,290,20,"Edit Element",,EXIT
DIALOG ADD,COMBO,C1,55,5,290,20,"Combo Element"
DIALOG ADD,LIST,L1,80,5,290,115
DIALOG ADD,STATUS,Stat,"Focus ="
DIALOG SHOW
rem -- No access to combo list items --
LIST ADD, L1, List Element
LIST LOADTEXT, C1,
"Option 1
"Option 2
"Option 3
"Option 4
:EVLOOP
WAIT EVENT
%e = @event()
DIALOG SET,Stat,"Focus = "@substr(%e, 1, @diff(@len(%e),5))
goto %e
:B1BUTTON
rem -- Not accessible --
INFO This is a BUTTON event...
goto EVLOOP
:E1EXIT
rem -- Not accessible --
INFO Edit EXIT event...
goto EVLOOP
:B1CLICK
:T1CLICK
:E1CLICK
:C1CLICK
:L1CLICK
INFO This is a CLICK event...
goto EVLOOP
:CLOSE
EXIT
|
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|
Back to top |
|
|
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Tue Aug 27, 2002 1:03 am Post subject: |
|
|
OK, here's a larger example of the first version for
edit boxes. This one uses loops to check 45 edit
boxes (0-44). It also uses offscreen edit boxes for
variables (an old VDS2 trick), because you can't
increment to another var in a loop (ie: %%var%x).
You can see the EVLOOP procedure is fairly small...
Code: |
OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,Test Program,-1,0,600,400
rem -- Column 1 --
%n = 0
%x = 0
REPEAT
DIALOG ADD,TEXT,T%n,@sum(@prod(%x, 25),3),5,,,"E"%n
DIALOG ADD,EDIT,E%n,@prod(%x, 25),28,167,20
rem -- Use offscreen edit boxes for vars, so we can use a loop --
DIALOG ADD,EDIT,Var%n,0,0,0,0
%n = @succ(%n)
%x = @succ(%x)
UNTIL @greater(%x, 14)
rem -- Column 2 --
%x = 0
REPEAT
DIALOG ADD,TEXT,T%n,@sum(@prod(%x, 25),3),205,,,"E"%n
DIALOG ADD,EDIT,E%n,@prod(%x, 25),228,167,20
rem -- Use offscreen edit boxes for vars, so we can use a loop --
DIALOG ADD,EDIT,Var%n,0,0,0,0
%n = @succ(%n)
%x = @succ(%x)
UNTIL @greater(%x, 14)
rem -- Column 3 --
%x = 0
REPEAT
DIALOG ADD,TEXT,T%n,@sum(@prod(%x, 25),3),405,,,"E"%n
DIALOG ADD,EDIT,E%n,@prod(%x, 25),428,167,20
rem -- Use offscreen edit boxes for vars, so we can use a loop --
DIALOG ADD,EDIT,Var%n,0,0,0,0
%n = @succ(%n)
%x = @succ(%x)
UNTIL @greater(%x, 14)
DIALOG ADD,STATUS,Stat
DIALOG SHOW
:EVLOOP
REPEAT
WAIT ".01"
%x = 0
REPEAT
if @not(@equal(@dlgtext(Var%x), @dlgtext(E%x)))
DIALOG SET, Var%x, @dlgtext(E%x)
DIALOG SET, Stat, E%x has the focus...
end
%x = @succ(%x)
UNTIL @greater(%x, 44)
%e = @event()
UNTIL %e
goto %e
:CLOSE
EXIT
|
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|
Back to top |
|
|
Skit3000 Admin Team
Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Tue Aug 27, 2002 5:18 pm Post subject: |
|
|
This is an expension for the first example, which automatic sends a | and a Backspace to the window, so you can see which one has the focus.
Code: |
OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,Test Program,-1,0,200,100
DIALOG ADD,TEXT,T1,8,5,,,"E1"
DIALOG ADD,EDIT,E1,5,25,170,20
DIALOG ADD,TEXT,T2,33,5,,,"E2"
DIALOG ADD,EDIT,E2,30,25,170,20
DIALOG ADD,TEXT,T3,58,5,,,"E3"
DIALOG ADD,EDIT,E3,55,25,170,20
DIALOG ADD,STATUS,Stat
DIALOG SHOW
rem -- Get current text to compare --
%%old1 = @dlgtext(E1)
%%old2 = @dlgtext(E2)
%%old3 = @dlgtext(E3)
:EVLOOP
REPEAT
WAIT ".01"
rem The only 2 lines added are this
window send,Test Program,@chr(124)
if @not(@equal(%%old1, @dlgtext(E1)))
%%old1 = @dlgtext(E1)
DIALOG SET, Stat, "E1 has the focus..."
end
if @not(@equal(%%old2, @dlgtext(E2)))
%%old2 = @dlgtext(E2)
DIALOG SET, Stat, "E2 has the focus..."
end
if @not(@equal(%%old3, @dlgtext(E3)))
%%old3 = @dlgtext(E3)
DIALOG SET, Stat, "E3 has the focus..."
end
rem And this one
window send,Test Program,@chr(8)
%e = @event()
UNTIL %e
goto %e
:CLOSE
EXIT
|
Last edited by Skit3000 on Thu May 29, 2003 1:53 pm; edited 1 time in total |
|
Back to top |
|
|
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Tue Aug 27, 2002 11:13 pm Post subject: |
|
|
Hey skit,
I think you might wanna test your posted example.
It doesn't work when you type in the edit boxes,
it keeps inserting "|" in the typed text.
Personally, I don't think it's a good idea to send chars
to the window when a user may be entering data...
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|
Back to top |
|
|
|
|
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 vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|