Notifications
Clear all

[Closed] dotnet listview rightclicking event

Hi there,

having a problem with a dotnet listview as i cannot find an event that fires when the listview gets right-clicked.

I’m already working with this one (works):

on lv1 click do print "left-clicked"
on lv1 doubleclick do print "double-clicked"

In comparison to this one (doesn’t work):


on lv1 rightclick do print "right-clicked"

Anybody has an idea?
Excuse my english, still learning

11 Replies

Nevermind, just found the solution i the MXS+Dotnet thread

For those of you who are interested, this is the way i took:

lv1 is my listview

on lv1 MouseDown arg do
(
fn RunContext1 = (print "Context 1")
fn RunContext2 = (print "Context 2")
fn RunContext3 = (print "Context 3")
fn RunContext4 = (print "Context 4")
fn RunContext5 = (print "Context 5")
fn RunContext6 = (print "Context 6")

------ Right click
if arg.button == lv1.mousebuttons.right then
(
contextMenu = dotNetObject "System.Windows.Forms.ContextMenu"
contextMenu.MenuItems.Clear()
dotnet.addeventhandler (contextMenu.MenuItems.Add("Context 1")) "Click" RunContext1
dotnet.addeventhandler (contextMenu.MenuItems.Add("Context 2")) "Click" RunContext2
dotnet.addeventhandler (contextMenu.MenuItems.Add("Context 3")) "Click" RunContext3
dotnet.addeventhandler (contextMenu.MenuItems.Add("Context 4")) "Click" RunContext4
dotnet.addeventhandler (contextMenu.MenuItems.Add("Context 5")) "Click" RunContext5
dotnet.addeventhandler (contextMenu.MenuItems.Add("Context 6")) "Click" RunContext6
pointTest = (dotNetObject "System.Drawing.Point" arg.x arg.y)
contextmenu.Show lv1 pointTest
)

----- Left click
if arg.button == lv1.mousebuttons.left then
(
print "left mouse button"
)
)
 lo1
	on lv1 mouseclick s e do
	(
		if e.Button == e.Button.right do print "rightclick"
	)
1 Reply
(@heilandzack)
Joined: 11 months ago

Posts: 0

One quesiton on that:

what is the s for?/what does it hold?

Thank you! that made it

Yeah getting right click to work on most .Net form objects is that simple unless you try it on a TreeView! then it just gets dumb

EDIT: Just confused here ! disregard!

what’s wrong with a treeview? i don’t remember any problem with the rightclick there.
probably you are talking about the behavior: it makes node focused on mouse buton pressed but doesn’t leave the node selected on button released. right?

Deleted post

 lo1

mouseDown/mouseUp events are always triggered by all buttons.

2 Replies
(@denist)
Joined: 11 months ago

Posts: 0

absolutely right. never use any Click event if there is a difference for you what button was clicked. use the pair of mouseDown/mouseUp events.

 lo1
(@lo1)
Joined: 11 months ago

Posts: 0

or mouseClick event.

s is short for sender, the dotnet object which triggered the event. In this case it contains your control.

Excuse my confusion… not enough coffee this morning please disregard my comment about the right click on treeViews… I was confusing it with something else! Right Click works fine! using mouseDown events and filtering which input you got from the user is the right way to go like Denis and lo stated here.