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

how to handle mouse click events on dfl.button.Button?

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



Joined: 21 May 2008
Posts: 2
Location: Poland

PostPosted: Wed May 21, 2008 2:39 pm    Post subject: how to handle mouse click events on dfl.button.Button? Reply with quote

Could anyone pass a code that shows how to handle right-click and middle-click mouse events on a button?
Code:

import dfl.all;

class MyForm: dfl.form.Form
{
   dfl.button.Button myButton;
   
   this() {
      myButton = new dfl.button.Button();
      myButton.text = "Click me";
      myButton.click ~= &clickedLeft;     // connects left-click event
      myButton.parent = this;
   }

   private void clickedLeft(Control sender, EventArgs ea) {
      msgBox("clicked LEFT mouse button");
   }

   // Where to plug this function?...
   // private void clickedRight(Control sender, EventArgs ea) {
   //    msgBox("clicked RIGHT mouse button");
   // }
}

void main() {
   Application.run(new MyForm());
}

Confused
Maybe button is not the best choice for right-click events, but I need a buttonlike functionality in overall...
Back to top
View user's profile Send private message
Chris Miller



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

PostPosted: Wed May 21, 2008 10:07 pm    Post subject: Re: how to handle mouse click events on dfl.button.Button? Reply with quote

click is specifically for left clicks, but you can use mouseDown and test for the right button.
Back to top
View user's profile Send private message
joshua



Joined: 21 May 2008
Posts: 2
Location: Poland

PostPosted: Thu May 22, 2008 4:18 am    Post subject: Reply with quote

Simplicity is bless... Wink
Yeap. That's it. Thanks Chris.
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