Hi
I have a PictureBox that reacts to click and doubleclick by doing 2 differents things, but the OnClick event is always triggered before OnDblClicked (same for OnMouseDown and OnMouseDblClick)...
How do you prevent OnClick when OnDblClicked ??
Hi, that's right, OnDoubleClick means automatically that OnClick was fired before (same in all other controls and AFAIK in all other programming languages).
Please have a look at MouseMove - it also will be called at OnClicked. So maybe you can check the time between two clicks.
Regards
Fred
Hi
Thanks.. if I include onMouseMove the sequences I get are :
- clic : (m) c m
- dbleclic : (m) c m d c c m
where : m = onMouseMove (+ a first (m) if the control hadn't focus) / c = onClicked / d = onDoubleClick
Not simple... :-(
I'll search how to use TIMER in these sequences, but meanwhile if someone has already made that...
Hi
I've tried something with dcl_DelayedInvoke... but this function has many inconvenients : can't prevent the command name on the command line (?) and especially the command became the last one in the interface, user accessible..
Please do you confirm that's a wrong way ?
(defun c:Untitled_Form1_PictureBox1_OnClicked (/)
(setvar "CMDECHO" 0) ; no ?
(setvar "NOMUTT" 1)
(or *double (dcl_DelayedInvoke 350 "Do"))
)
(defun c:Untitled_Form1_PictureBox1_OnDblClicked (/)
(setq *double T)
)
(defun c:Do ()
(if *double (princ "\nClicClic!") (princ "\nClic!"))
(setq *double nil)
(setvar "CMDECHO" 1)
(setvar "NOMUTT" 0)
(princ)
)
I think you are fighting a losing battle, and you should change your design instead.
Hi krunch,
Maybe we should focus on WHY it is necessary to separate OnClick from OnDblClick. Maybe there are other solutions for that.
An (very up-to-date) example: I have a list view. When I click on an item, OnClick will be called and immediately the event function takes a look into a database with a complex query and shows the result in a grid (!!!) below the listview. Works fine. But clearing the grid, executing the SQL command and refilling the grid takes a recognizeble amount of time. So when I doublick an item, a subform has to be shown. But since OnClicked is fired, too, before OnDblClicked could be fired, the time is over that Windows could recognize my double click as a double click and it accepts it for two single clicks >:( That's why I introduced a intLastClick variable to store the latestly selected listview item to leave the content of OnClick event out and finally Windows recognizes my double click as a double click.
So that's why I think we should talk about what you're trying to do and maybe we'll find a solution.
Regards,
Fred
[EDIT] Owen said the sentence of my post in a much shorter way :)
Hi, thanks for your answers
Yes, that the same problem : OnClick triggers before OnDoubleClick and make unwanted result, that's why I start from triggers order..
So, what I make is a "button" (a PictureBox indeed) that inverse(-) on click / erase a value onDoubleClick... the value is in a textbox, the button is before (contiguous) the textbox.. simple!
The problem is not only "esthetic" (the fact that I see "-" for a split second before the value is erased), because some textboxes must receive "1" instead of "" (erase) on doubleclick (scale factor).. so in that case I get "-1" and not "1"..
So I think I have to separate the 2 events
Hoping to have been explicit..
Regards
Hm, krunch, I wanna play around with that. Would you be so kind to create a small example to demonstrate? Maybe with only the image (as button) and the textbox. Thing what I cannot imagine, is, that I don't believe that the customer is familiar with that procedure. But maybe I would change my mind if I "feel" it by myself. by default I'd use 2 different buttons for two different actions. Or you devide the image in the left area and the right area ...
Regards,
Fred
Hi
Sure!.. I made a simplified sample..
I precise that :
It's for this project (http://www.opendcl.com/forum/index.php?topic=1558.0) (end of the page), so there's not 2 but 9 textboxes (may be +3 for columns), and when you click or doubleclick it updates the transformation...
The buttons (which will be more discrete and small) are placed in front of each textbox, and I manage inputs with my "Get_ControlName" function (http://www.opendcl.com/forum/index.php?topic=1555.0) (btw I've also made a feature request here (http://sourceforge.net/tracker/?func=detail&aid=3185214&group_id=187950&atid=923366))
QuoteThing what I cannot imagine, is, that I don't believe that the customer is familiar with that procedure
As I try it I think it's really easy to adopt..
Thanks for interest
Regards
Ok I think I give up.. :(
According to the sequences there's no perfect way. I could wait at the next OnMouseMove afer OnClicked-OnMouseMove but it means that a simple click is "validated" by this next OnMouseMove, so it's triggered only when I move after click..
I think I will make a button divided into 2 parts (+/- up and reset down)... or maybe right-clic for reset / left-clic for inverse (+/-) ?
Thanks
Please do you confirm there's now way for the particularity of dcl_DelayedInvoke (can't prevent the command name on the command line (?) and especially the command became the last one in the interface, user accessible..) and no way to DelayedInvoke a standart function (not c:) ? Thanks in advance
Hi, krunch, sorry, I haven't seen your sample yet. I'll try it later this evening.
Fred
Hello, krunch,
hm, have you ever thought about right click on the imagebutton?
On the other hand I've found out that OnClicked will be fired twice so I hope Owen could pay attention to this topic again. :)
I've changed your sample and I attached it again. When you doubleclick an imagebutton, you can see the following lines in the command line.
PictureBox1_OnClicked
PictureBox1_OnDblClicked
PictureBox1_OnClicked
I'm not sure whether this behaviour is wanted. Maybe Owen can light up this for us.
I'll recommend you to use two different buttons for two different things - otherwise you will have to fight battles with your customers. I mean discussions about usability.
Regards,
Fred
Yes I came to the same conclusion : when DoubleClicked there's no way to prevent the 1st OnClicked event.. except with a delayed device, but DelayedInvoke operates as an AutoCad command, so it's no good :(
Thanks Fred
Fred, I'm not sure what exactly I'm supposed to test to reproduce this. Can you attach sample files in a new reply?
Hi, Owen, sorry, I've forgotten to attach.
The thing is, that OnClicked will be fired twice when you doubleclick on the image.
Fred
I'm not sure why the OnClicked event gets triggered in this case, but I've hacked a workaround for the next build that should solve the problem.