Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Click and Double-Click issue 3

Status
Not open for further replies.

Scott24x7

Programmer
Jul 12, 2001
2,826
JP
Hi all,
Haveing an odd issue with Click and Double-Click events.
No matter how quickly I double click, my click event fires first, and then the double click-event, though I'm only looking for the double click event to fire. Is there some way to fix this? A timer property for click at a global level of some type?


Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Mike, dead simple.

Load your image into Photoshop. Change the color of key elements of the image (lots of ways to do this, especially with icons that use a very small number of colors). Just replace it with a "lighter" version of the color.

Then:

In the MouseEnter event:

This.Picture = "<path to picture>.PNG" && I use PNG because I can make them transparent.

In the MouseLeave:

This.Picture = "<path to pictures>.PNG" && Same as above, but this picture is the one you had it set to default to start with.

That's all there is to it.
In an old application, I had a different image again for MouseDown, it was on a company logo, and a messagebox would pop up and say "Hey, stop clicking our logo". :)

So we made the image brighter still, and when MouseUp, back to 2nd glowing image, and mouse leave, always return to original image.


Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
I like this discussion.
Please allow me to add that if the object has a caption with a hotkey, then when :

1) The object has the focus (commandbutton, checkbox, optionbutton)
a) pressing the hotkey, first triggers keypress, then click, and finally container's click (if is the case, like optiongroup)
b) pressing Alt+hotkey, triggers only click, and finally container's click (if is the case, like optiongroup)

2) Another object has the focus
a) pressing the hotkey, first triggers keypress for object's which has the focus, then the target object's gotfocus, and then its click, and finally container's click (if is the case, like optiongroup)
b) pressing Alt+hotkey, triggers the target object's gotfocus, then its click, and finally container's click (if is the case, like optiongroup)

3) the object is a label; the label object behaves different, because it can receive the focus
a) pressing the hotkey, first triggers keypress for object's which has the focus, and then the target object's gotfocus (the first contained object, if the target is a container)
b) pressing Alt+hotkey, triggers the target object's gotfocus (the first contained object, if the target is a container)

Tested only with commandbutton, checkbox, textbox, optiongroup and label
Code:
PUBLIC ofrm
ofrm = CREATEOBJECT("MyForm")
ofrm.show()

DEFINE CLASS MyForm as Form
	ADD OBJECT txt as textbox
	ADD OBJECT cmd as commandbutton with caption ="\<Test",top = 50
	ADD OBJECT chk as checkbox with caption ="T\<est",top = 100
	ADD OBJECT lbl as label with caption ="Te\<st",top = 150
	ADD OBJECT txt2 as textbox WITH top = 200
	ADD OBJECT lbl2 as label with caption ="Test \<2",left = 200
	ADD OBJECT opt as optiongroup WITH left = 200,top = 50,buttoncount = 2,autosize = .T.
	PROCEDURE init
		STORE .T. TO This.opt.buttons[1].Autosize,This.opt.buttons[2].Autosize
		This.opt.buttons[1].Caption = "\<But"
		This.opt.buttons[2].Caption = "B\<ut"
		BINDEVENT(This.cmd,'click',This,'MyClick')
		BINDEVENT(This.cmd,'keypress',This,'MyKeypress')
		BINDEVENT(This.cmd,'gotfocus',This,'MyClick')
		BINDEVENT(This.chk,'click',This,'MyClick')
		BINDEVENT(This.chk,'keypress',This,'MyKeypress')
		BINDEVENT(This.chk,'gotfocus',This,'MyClick')
		BINDEVENT(This.lbl2,'click',This,'MyClick')
		BINDEVENT(This.lbl2,'gotfocus',This,'MyClick')
		BINDEVENT(This.opt,'click',This,'MyClick')
		BINDEVENT(This.opt.buttons[1],'click',This,'MyClick')
		BINDEVENT(This.opt.buttons[1],'keypress',This,'MyKeypress')
		BINDEVENT(This.opt.buttons[1],'gotfocus',This,'MyClick')
		BINDEVENT(This.opt.buttons[2],'click',This,'MyClick')
		BINDEVENT(This.opt.buttons[2],'keypress',This,'MyKeypress')
		BINDEVENT(This.opt.buttons[2],'gotfocus',This,'MyClick')
		BINDEVENT(This.lbl,'click',This,'MyClick')
		BINDEVENT(This.lbl,'gotfocus',This,'MyClick')
		BINDEVENT(This.txt2,'click',This,'MyClick')
		BINDEVENT(This.txt2,'keypress',This,'MyKeypress')
		BINDEVENT(This.txt2,'gotfocus',This,'MyClick')
	ENDPROC
		
	PROCEDURE myclick
		LOCAL lae[1]
		AEVENTS(lae,0)
		ACTIVATE SCREEN 
		? lae[1].name,lae[2]
	ENDPROC
	PROCEDURE mykeypress
		LPARAMETERS nkey,nshift
		LOCAL lae[1]
		AEVENTS(lae,0)
		ACTIVATE SCREEN 
		? lae[1].name,lae[2]
	ENDPROC
ENDDEFINE


Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
Nice idea to use all these BINDEVENTS and also include the keypress events. I'd display SECONDS() and handle the reset of a click counter and initial click time in mousedown, as we can surely all agree it fires with every click start. Of course Eventtracking could also be used to get an ooutput of the events happening, but you'll never see which branch of code executes in the events via eventttracking and bindevents alone, the if/else branch has to add to the log file as well.

Overall my outcome of this is the native events already are sufficient.

And Scott, I like your idea of the glowing image, I once started doing 3d buttons via image control which changed to a hovered version of the buttons when hovering over them with the mouse. But I was beaten by Bernard Bout, who did this:

or

You'll find lots more done by him in his blog category GDI+X

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top