Page 1 of 2 12>
Topic Options
#90598 - 2002-12-18 01:10 AM Kixforms: Which mouse button was clicked?
krabourn Offline
Hey THIS is FUN
*****

Registered: 2000-12-11
Posts: 244
Loc: San Antonio, Texas, USA
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
_________________________
Kelly

Top
#90599 - 2002-12-18 02:06 AM Re: Kixforms: Which mouse button was clicked?
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
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 ]

Top
#90600 - 2002-12-18 05:31 PM Re: Kixforms: Which mouse button was clicked?
krabourn Offline
Hey THIS is FUN
*****

Registered: 2000-12-11
Posts: 244
Loc: San Antonio, Texas, USA
Head slap!

I was using .OnMouseUp instead of .OnMouseDown.

Thanks
_________________________
Kelly

Top
#90601 - 2002-12-18 05:40 PM Re: Kixforms: Which mouse button was clicked?
krabourn Offline
Hey THIS is FUN
*****

Registered: 2000-12-11
Posts: 244
Loc: San Antonio, Texas, USA
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

_________________________
Kelly

Top
#90602 - 2002-12-18 05:45 PM Re: Kixforms: Which mouse button was clicked?
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
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 ?
Top
#90603 - 2002-12-18 05:49 PM Re: Kixforms: Which mouse button was clicked?
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
I think that'll maybe just the same like setting process priorities in Task Manager ?
_________________________



Top
#90604 - 2002-12-18 05:54 PM Re: Kixforms: Which mouse button was clicked?
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
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.
Top
#90605 - 2002-12-18 06:01 PM Re: Kixforms: Which mouse button was clicked?
krabourn Offline
Hey THIS is FUN
*****

Registered: 2000-12-11
Posts: 244
Loc: San Antonio, Texas, USA
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.
_________________________
Kelly

Top
#90606 - 2002-12-18 06:05 PM Re: Kixforms: Which mouse button was clicked?
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
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.
Top
#90607 - 2002-12-18 07:01 PM Re: Kixforms: Which mouse button was clicked?
krabourn Offline
Hey THIS is FUN
*****

Registered: 2000-12-11
Posts: 244
Loc: San Antonio, Texas, USA
OK, what is the trick. I was thinking

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

Top
#90608 - 2002-12-18 07:02 PM Re: Kixforms: Which mouse button was clicked?
krabourn Offline
Hey THIS is FUN
*****

Registered: 2000-12-11
Posts: 244
Loc: San Antonio, Texas, USA
Nevermind I stransposed the variables in the popup function.
_________________________
Kelly

Top
#90609 - 2002-12-18 07:04 PM Re: Kixforms: Which mouse button was clicked?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
eh?
have never tried those functions (time to do it?) but I think shawn, your question will be answered [Wink]
_________________________
!

download KiXnet

Top
#90610 - 2002-12-18 07:11 PM Re: Kixforms: Which mouse button was clicked?
krabourn Offline
Hey THIS is FUN
*****

Registered: 2000-12-11
Posts: 244
Loc: San Antonio, Texas, USA
I guess I did not actually answer the question.

YES. [Smile]
_________________________
Kelly

Top
#90611 - 2002-12-18 07:29 PM Re: Kixforms: Which mouse button was clicked?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ee?
kra, did I understand your last post at all? not!

so, do you have that code or not?
_________________________
!

download KiXnet

Top
#90612 - 2002-12-18 07:41 PM Re: Kixforms: Which mouse button was clicked?
krabourn Offline
Hey THIS is FUN
*****

Registered: 2000-12-11
Posts: 244
Loc: San Antonio, Texas, USA
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

_________________________
Kelly

Top
#90613 - 2002-12-18 07:44 PM Re: Kixforms: Which mouse button was clicked?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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...
_________________________
!

download KiXnet

Top
#90614 - 2002-12-18 07:45 PM Re: Kixforms: Which mouse button was clicked?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
btw, will use this code at checker so if you find any strugle, I'd like to know...
_________________________
!

download KiXnet

Top
#90615 - 2002-12-18 07:50 PM Re: Kixforms: Which mouse button was clicked?
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Krabourn: Sweet !

Jooel: Sweet !

-Shawn

Top
#90616 - 2002-12-18 07:55 PM Re: Kixforms: Which mouse button was clicked?
krabourn Offline
Hey THIS is FUN
*****

Registered: 2000-12-11
Posts: 244
Loc: San Antonio, Texas, USA
This makes it start at the mouse. Why do I need to add these numbers?

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

_________________________
Kelly

Top
#90617 - 2002-12-18 07:56 PM Re: Kixforms: Which mouse button was clicked?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
?
one reason is the border calculation of board
_________________________
!

download KiXnet

Top
Page 1 of 2 12>


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
2 registered (morganw, mole) and 414 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.105 seconds in which 0.061 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org