1. Dave, how do I detect double clicks on List items?
- Posted by Derek Brown <Cyrusbrown at AOL.COM>
Sep 07, 1999
-
Last edited Sep 08, 1999
Dave,
What I'm trying to do is open a window that edits list items when you
double click them. I already have a pushbutton to do it, but for sake of
shortcut the double click would be nice.
First I tried by making a variable called clicked. Here is the onChange
routine for the list:
if clicked = getIndex(List01) then
openWindow(Win2,Modal)
else
clicked = getIndex(List01)
end if
The only problem is the program runs through the above procedure twice. So
it then put in a skip variable, which alternates between off and on. If skip
= off then it will do the above, else skip = on. However, now it takes five
clicks to open Win2. Below is the test code I used. I'm trying to put this
feature in all my lists for my game, so if I can figure out the problem in
the test I can translate it easily.
Any suggestions?
Thanks,
Derek Brown
include win32lib.ew
without warning
integer clicked, skip
with trace
--trace(1)
constant
Win = create(Window,"Win",0,100,100,300,300,0),
Win2 = create(Window,"Win2",0,150,150,150,150,0),
List01 = create(List,"",Win,10,10,200,250,0)
procedure OpenWin()
addItem(List01,"ONE")
addItem(List01,"TWO")
addItem(List01,"THREE")
addItem(List01,"FOUR")
addItem(List01,"FIVE")
clicked = 0
skip = 0
setIndex(List01,1)
end procedure
procedure Update()
if skip = 0 then skip = 1 else skip = 0 end if
if skip = 0 then
if clicked = getIndex(List01) then
openWindow(Win2,Modal)
clicked = 0
else
clicked = getIndex(List01)
end if
end if
end procedure
procedure CloseWin2()
clicked = 0
end procedure
onOpen[Win] = routine_id("OpenWin")
onChange[List01] = routine_id("Update")
onClose[Win2] = routine_id("CloseWin2")
WinMain(Win,Normal)
2. Re: Dave, how do I detect double clicks on List items?
Derek Brown wondered:
> What I'm trying to do is open a window that edits
> list items when you double click them
Use onMouse to trap the double click. Here's an example:
procedure Mouse( integer event, integer x, integer y )
if event = LEFT_DOUBLECLICK then
-- your code goes here...
end if
end procedure
onMouse[List01] = routine_id("Mouse")
-- David Cuny