krabourn
(Hey THIS is FUN)
2002-12-18 01:10 AM
Kixforms: Which mouse button was clicked?

I am trying to add a right click menu. How can you tell which button was clicked? When I test for a click, I loose which button was clicked.

Thanks


ShawnAdministrator
(KiX Supporter)
2002-12-18 02:06 AM
Re: Kixforms: Which mouse button was clicked?

Hi krabourn,

Try using the OnMouseDown event in combination with the Form's MouseButton property - heres an example. Just right click anywhere on the form. Dont forget - the MouseX and MouseY position is in Client Coordinates (relative to the top left of the form, not the desktop) and Forms are specified using real coordinates (from the top left of the desktop) ...

code:
Break On

$Form = CreateObject("Kixtart.Form")
$Form.Size = 400, 400
$Form.Center
$Form.ForeColor = Blue
$Form.OnMouseDown = "OnFormMouseDown"

Function OnFormMouseDown
If $Form.MouseButton = 2 ; Right-click
$Form.PrintXY($Form.MouseX,$Form.MouseY,"Here I am")
EndIf
EndFunction

$Form.Show
While $Form.Visible
$=Execute($Form.DoEvents())
Loop

Exit 1



[ 18. December 2002, 02:07: Message edited by: Shawn ]


krabourn
(Hey THIS is FUN)
2002-12-18 05:31 PM
Re: Kixforms: Which mouse button was clicked?

Head slap!

I was using .OnMouseUp instead of .OnMouseDown.

Thanks


krabourn
(Hey THIS is FUN)
2002-12-18 05:40 PM
Re: Kixforms: Which mouse button was clicked?

Can you make this work with .ListView in future releases? Of course we will probably be asking for this in other object too.

I will have to wait. I am not sure how I would translate a pixel location to a row in the .ListView.

My current code.
code:
$lvwNames.OnMouseDown = 'fnlvwNamesMouseRight_Down()'
FUNCTION fnlvwNamesMouseRight_Down()
? 'In'
? $frmWMAInventory.MouseButton
IF $lvwNames.MouseButton = 2
? 'Hi'
ENDIF
ENDFUNCTION



ShawnAdministrator
(KiX Supporter)
2002-12-18 05:45 PM
Re: Kixforms: Which mouse button was clicked?

I'll have a play with your code here but what neat things are you trying to accomplish - you wanting to position a tooltip-type thingy over a particular row - or a popup menu over a row ?

JochenAdministrator
(KiX Supporter)
2002-12-18 05:49 PM
Re: Kixforms: Which mouse button was clicked?

I think that'll maybe just the same like setting process priorities in Task Manager ?

ShawnAdministrator
(KiX Supporter)
2002-12-18 05:54 PM
Re: Kixforms: Which mouse button was clicked?

Was just playing with krabourns code there - notice that if you have a single column listview, and you right click just to the right side of a row (to the the right of the column) then the click gets through - for clicking inside a row will have to expose some special handling for that - these are trapped by the ListView itself and Ill just filter it back out through the MouseX/MouseY/Button interface.

krabourn
(Hey THIS is FUN)
2002-12-18 06:01 PM
Re: Kixforms: Which mouse button was clicked?

This is more playing at the moment. I have simple database front end that accesess a .ini file, at the moment. This that keeps track of computers I control. Info such as computer name, computer domain, IP, User ID, User Name and User Phone.

I thought it would be cool to add a right click popup menu. It would do the same things that the menu buttons do.

I don't have a web page to show you what it looks like.


ShawnAdministrator
(KiX Supporter)
2002-12-18 06:05 PM
Re: Kixforms: Which mouse button was clicked?

Have you been successfull in getting the form to popup over the MouseX/MouseY coordinates ? Like I eluded to earlier, there are some tricks to converting relative client coordinates to physical screen coordinates for properly positioning a popup form.

krabourn
(Hey THIS is FUN)
2002-12-18 07:01 PM
Re: Kixforms: Which mouse button was clicked?

OK, what is the trick. I was thinking

$Form.Left + $Form.MouseX
$Form.Top + $Form.MouseY


krabourn
(Hey THIS is FUN)
2002-12-18 07:02 PM
Re: Kixforms: Which mouse button was clicked?

Nevermind I stransposed the variables in the popup function.

LonkeroAdministrator
(KiX Master Guru)
2002-12-18 07:04 PM
Re: Kixforms: Which mouse button was clicked?

eh?
have never tried those functions (time to do it?) but I think shawn, your question will be answered [Wink]


krabourn
(Hey THIS is FUN)
2002-12-18 07:11 PM
Re: Kixforms: Which mouse button was clicked?

I guess I did not actually answer the question.

YES. [Smile]


LonkeroAdministrator
(KiX Master Guru)
2002-12-18 07:29 PM
Re: Kixforms: Which mouse button was clicked?

ee?
kra, did I understand your last post at all? not!

so, do you have that code or not?


krabourn
(Hey THIS is FUN)
2002-12-18 07:41 PM
Re: Kixforms: Which mouse button was clicked?

Sorry, I am sick at home today and my brain is not firing on all two cylinders.

Here is the code. It is not even close to perfect. It is just some proof of concept.

code:
Break On

$Form = CreateObject("Kixtart.Form")
$Form.Size = 400, 400
$Form.Center
$Form.ForeColor = Blue
$Form.OnMouseDown = "OnFormMouseDown"
FUNCTION OnFormMouseDown
If $Form.MouseButton = 2
; Right-click
fnPopup($Form.Left + $Form.MouseX, $Form.Top + $Form.MouseY)
ENDIF
EndFunction

$Form.Show
While $Form.Visible
$=Execute($Form.DoEvents())
Loop

Exit 1

FUNCTION fnPopup($FormSLeft, $FormSTop)
$FormS = CreateObject("Kixtart.Form")
$FormS.BorderStyle = 0
$FormS.ClientWidth = 100
$FormS.ClientHeight = 35
$FormS.Top = $FormSTop
$FormS.Left = $FormSLeft
$FormS.ForeColor = Red
$FormS.Show
$FormS.Rectangle(0, 0, $FormS.ClientWidth, $FormS.ClientHeight)
$btnClose = $FormS.CommandButton("Click Me", 10, 5, 80, 25)
$btnClose.OnClick = "$$FormS.Hide"
While $FormS.Visible
$=Execute($FormS.DoEvents())
Loop
ENDFUNCTION



LonkeroAdministrator
(KiX Master Guru)
2002-12-18 07:44 PM
Re: Kixforms: Which mouse button was clicked?

so, sorry, is the consept to have the popup at the ...
mm..
so, do we want the popup left/top under the mouse, or do we want it centered around the mouse?

I quess this could shoot a msgbox() udf...


LonkeroAdministrator
(KiX Master Guru)
2002-12-18 07:45 PM
Re: Kixforms: Which mouse button was clicked?

btw, will use this code at checker so if you find any strugle, I'd like to know...

ShawnAdministrator
(KiX Supporter)
2002-12-18 07:50 PM
Re: Kixforms: Which mouse button was clicked?

Krabourn: Sweet !

Jooel: Sweet !

-Shawn


krabourn
(Hey THIS is FUN)
2002-12-18 07:55 PM
Re: Kixforms: Which mouse button was clicked?

This makes it start at the mouse. Why do I need to add these numbers?

code:
	$FormS.Top = $FormSTop + 30
$FormS.Left = $FormSLeft + 5



LonkeroAdministrator
(KiX Master Guru)
2002-12-18 07:56 PM
Re: Kixforms: Which mouse button was clicked?

?
one reason is the border calculation of board


krabourn
(Hey THIS is FUN)
2002-12-18 08:09 PM
Re: Kixforms: Which mouse button was clicked?

I used my wonderful Yahoo account and set myself up an account with GeoCities.

Here is a screenshot. Pretend there is a normal windows border around it.

Boy it looks ugly through a browser.

http://www.geocities.com/krabourn@sbcglobal.net/

[ 18. December 2002, 20:20: Message edited by: krabourn ]


LonkeroAdministrator
(KiX Master Guru)
2002-12-18 08:11 PM
Re: Kixforms: Which mouse button was clicked?

eh?

krabourn
(Hey THIS is FUN)
2002-12-18 08:36 PM
Re: Kixforms: Which mouse button was clicked?

Push.

I never noticed before that edits did not show up in bbChecker.


LonkeroAdministrator
(KiX Master Guru)
2002-12-18 08:37 PM
Re: Kixforms: Which mouse button was clicked?

edits?

krabourn
(Hey THIS is FUN)
2002-12-18 08:42 PM
Re: Kixforms: Which mouse button was clicked?

You know. The Edit/Delete Button. [Wink]

I am running 1.6.1.1.

===================
Testing an edit.

[ 18. December 2002, 20:46: Message edited by: krabourn ]


LonkeroAdministrator
(KiX Master Guru)
2002-12-18 08:43 PM
Re: Kixforms: Which mouse button was clicked?

eh, do they show up in today's actives either?

checker does not do wonders you know ...

well, small ones, but.


krabourn
(Hey THIS is FUN)
2002-12-18 08:57 PM
Re: Kixforms: Which mouse button was clicked?

Not sure. This subject is in Today's with edits.