Notifications
Clear all

[Closed] Doubleclick anomaly

here we have a simple button that works fine as click trigers required event, but doubleclick does nothing>


 (
fn buttonPressed2 a1 =
(
print "2. Button Pressed - One Argument"
print a1
)
fn buttonPressed3 =
(
print "3. Button Pressed - No Arguments"
)

local mButton = dotNetObject "System.windows.forms.button"
mButton.text = "Press Me"
mButton.size = dotNetObject "System.Drawing.Size" 100 100
mButton.location = dotNetObject "System.Drawing.Point" 10 10
local hForm = dotNetObject "System.Windows.Forms.Form"
hForm.size = dotNetObject "System.Drawing.Size" 300 360
hForm.controls.add mButton
dotNet.addEventHandler mButton "click" buttonPressed3
dotNet.addEventHandler mButton "doubleclick" buttonPressed2
hForm.show()
)

 

What am I missing here?

4 Replies

a button never fired a double-click event when using old win32-api (old but still useful and fast)
wild guess: also not in .net
try to use another control if possible, which supports dblclk

but what do i know…m i’m not a big .net-fan/-user …
guruware

i’m a big fan of using .net and .net ui elements. because using it makes everything possible.
standard Forms.Button doesn’t fire DoubleClick and MouseDoubleClick events because by default it’s control style doesn’t set to StandardDoubleClick.
so, to make it works we have to set it by using Reflection and type’s “SetStyle” method invoke…

but an easier solution is to use MouseDown event and check number of clicks:

try(form.close()) catch()
 form = dotNetObject "MaxCustomControls.Maxform"
 
 bt = dotnetobject "Button"
 bt.Backcolor = bt.Backcolor.Transparent
 bt.Text = "Button"
 
 fn onMouseDown s e =
 (
     format ">> Mouse Down - %
" e.Clicks
 )
 dotnet.addeventhandler bt "MouseDown" onMouseDown
 
 form.controls.add bt
 form.showmodeless()

yes, that’s actually better because you only need one event handler for both clicks.thnx denis