Skip to main content

Button_Click method - Determine what the mouse button was pressed.

  • December 10, 2013
  • 2 replies
  • 0 views

Hi, again.

I do "set  btn to sender as type Button" and i can get button properts.

Now i need to get which mouse button has brought me here.


I suspect that the answer is in "e as type System.EventArgs", but, how?

I asked to google...

hugs.

2 replies

Chris Glazier
Forum|alt.badge.img+2
  • Moderator
  • December 10, 2013

Hi, again.

I do "set  btn to sender as type Button" and i can get button properts.

Now i need to get which mouse button has brought me here.


I suspect that the answer is in "e as type System.EventArgs", but, how?

I asked to google...

hugs.

Try using the MouseDown event instead of the Clicked event of the button:

Example:

       method-id button1_MouseDown final private.
       procedure division using by value sender as object e as type System.Windows.Forms.MouseEventArgs.
           if e::Button = type MouseButtons::Left
              set textBox1::Text to "left"
           else
              if e::Button = type MouseButtons::Right
                 set textBox1::Text to "right"
              end-if
           end-if
           
       end method.

Hi, again.

I do "set  btn to sender as type Button" and i can get button properts.

Now i need to get which mouse button has brought me here.


I suspect that the answer is in "e as type System.EventArgs", but, how?

I asked to google...

hugs.

Thank you very much, Mr. Chris.

It´s easy, when you know.