FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SHIFT key + label_doubleClick

 
Post new topic   Reply to topic     Forum Index -> DFL
View previous topic :: View next topic  
Author Message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Mon Oct 01, 2007 3:13 pm    Post subject: SHIFT key + label_doubleClick Reply with quote

Greetings.

Is there a way to tell if the shift key is being pushed, while a label (say label_2) is double clicked? I am adding 1 to a value while double clicking on label_2, but I want to add 5 when the shift key is down.

Is this possible or is there any other way of doing this?

thanks,

jic
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Tue Oct 02, 2007 12:56 am    Post subject: Re: SHIFT key + label_doubleClick Reply with quote

You can just test if(Control.modifierKeys & Keys.SHIFT) in your click handler.
Back to top
View user's profile Send private message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Tue Oct 02, 2007 7:17 am    Post subject: Reply with quote

thanks. That worked.
Back to top
View user's profile Send private message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Tue Oct 02, 2007 12:43 pm    Post subject: Reply with quote

The first double click with the SHIFT key pressed does not work. For example, I press the SHIFT key and then I double click on the label and the wrong event gets executed (the one with the SHIFT key not pressed). Any idea how to make it work correctly?

thanks,

jic
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Wed Oct 03, 2007 9:06 am    Post subject: Reply with quote

It seems to be working good here. I might need more info to help.
Back to top
View user's profile Send private message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Wed Oct 03, 2007 4:08 pm    Post subject: Reply with quote

if it is working for you, I must be doing something wrong... .-)

I'll try to figure it out.

thanks.
Back to top
View user's profile Send private message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Thu Oct 11, 2007 1:54 pm    Post subject: Reply with quote

just to complete the thread, I was not doing something wrong, but I was missing another spot that I was not checking for the click handler.

DFL is great! Thanks!

jic
Back to top
View user's profile Send private message
baxissimo



Joined: 23 Oct 2006
Posts: 241
Location: Tokyo, Japan

PostPosted: Thu Nov 15, 2007 11:46 pm    Post subject: Re: SHIFT key + label_doubleClick Reply with quote

Chris Miller wrote:
You can just test if(Control.modifierKeys & Keys.SHIFT) in your click handler.


I think a better way is to pass the current key state along with the MouseEventArgs. The wParam for WM_MOUSEMOVE tells you right there what the modifier key state is, so you might as well pass it along to the user.
(http://msdn2.microsoft.com/en-us/library/ms645616.aspx)

Relying on GetAsyncKeyState is not so good because (I think) there's no equivalent to it on some platforms. So it could be a problem going forward with the GTK port and other ports in the future.

Anyway, I was surprised to find that the key state was not passed as part of the mouse event args. I think it should be added.
Back to top
View user's profile Send private message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Fri Nov 16, 2007 10:43 am    Post subject: Reply with quote

I agree. And also, there should be a way of passing variables to those event functions. I like passing variables to functions, but there is not way, that I know of, of passing my variables to these functions.

just a thought...

jic
Back to top
View user's profile Send private message
baxissimo



Joined: 23 Oct 2006
Posts: 241
Location: Tokyo, Japan

PostPosted: Fri Nov 16, 2007 2:55 pm    Post subject: Reply with quote

jicman wrote:
there should be a way of passing variables to those event functions. I like passing variables to functions, but there is not way, that I know of, of passing my variables to these functions.

just a thought...

jic


You mean something like this?
Code:

     setCallback(&myfunction, &myData);
     ...
     myfunction(EventArgs ea, void *yourData) {
          // yourData points to myData
     }


Well I've seen that done in various C-ish callback schemes (such as in FLTK), but I don't think that's so necessary in D.

For one, D has delegates, so the function you're passing as a callback already has a sort of "myData" pointer in it that points to the enclosing context. If a method delegate it points to the enclosing class, if function delegate it points to the enclosing scope. So you can stick your myData in that enclosing scope.

And for D2.0 with real closures now, it's even less of a necessity, because you really will be able to wrap up whatever data you want in a function. Something like:
Code:

    exitButton.click ~= (Object s,EventArgs a){
              onExitWithData(s,a, myData);
    };


With closures myData can be anything in the enclosing scope or a new value if you prefer or whatever. Proper closures means it will make it through in tact to the onExitWithData call, whenever that happens.

That's assuming DFL is going to move to D2.0 eventually.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DFL All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group