MouseDown versus MouseUp?

Using Microsoft Windows Presentation Foundation and Syncfusion WPF Libraries

MouseDown versus MouseUp?

Postby Dick Bowman on Wed Aug 12, 2015 2:20 pm

Can someone explain in simple terms why I can get a callback to work on a MouseUp event but not on MouseDown?

If I use the old Dyalog GUI controls both MouseDown and MouseUp work as expected/wanted, session snippet (you can work out what's in <owdown> and <owup>)...

f←⎕new 'Form' ''
f.onMouseDown←'owdown'
f.onMouseUp←'owup'
f.Wait
ow, you pressed me
that's a relief

But if I try the exact equivalent in a WPF/XAML-defined Window only the MouseUp event fires.

I see exactly equivalent (mis)behaviour with the KeyDown and KeyUp events.

Web search turns up the gnomic "MouseDown will only be bubbled from a hittable element"; but no matter how hard I hit the mouse/key nothing happens on the way down.
Visit http://apl.dickbowman.com to read more from Dick Bowman
User avatar
Dick Bowman
 
Posts: 235
Joined: Thu Jun 18, 2009 4:55 pm

Re: MouseDown versus MouseUp?

Postby PGilbert on Thu Aug 13, 2015 12:23 am

Hello Dick, this is working for me:

Code: Select all
      ∇MouseDown[⎕]∇
[0]   MouseDown(sender event)
[1]   ⎕←'MouseDown at position: ',event.GetPosition sender

      ∇MouseUp[⎕]∇
[0]   MouseUp(sender event)
[1]   ⎕←'MouseUp at position: ',event.GetPosition sender

      ⎕USING←'System.Windows,WPF/PresentationFramework.dll'
      win ← ⎕NEW Window
      win.onMouseDown ← 'MouseDown'
      win.onMouseUp   ← 'MouseUp'
      win.Show


When you click on the Window the events MouseDown and MouseUp are fired.
User avatar
PGilbert
 
Posts: 436
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: MouseDown versus MouseUp?

Postby MikeHughes on Thu Aug 13, 2015 7:00 am

It's a well documented bug. Apparently the default handler sets the Handled property to 1.

The recommended work around is to use Preview mouse Down
User avatar
MikeHughes
 
Posts: 86
Joined: Thu Nov 26, 2009 9:03 am
Location: Market Harborough, Leicestershire, UK


Return to WPF & Syncfusion

Who is online

Users browsing this forum: No registered users and 1 guest