MouseUp or MouseDown?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
RossG
Posts: 247
Joined: Thu Jan 08, 2015 7:38 am

MouseUp or MouseDown?

Post by RossG » Thu Jun 07, 2018 10:33 pm

I've long been intrigued by the default
"on mouseUp" since "on mouseDown" seems
more intuitive and I've recently found that
in some cases "mouseDown" works better.

Is there some history in the use of "mouseUp"?
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: MouseUp or MouseDown?

Post by FourthWorld » Fri Jun 08, 2018 12:53 am

With push buttons on most OSes, the release of the mouse is the action trigger. Your can observe this by clicking down on a push button, and while the mouse is still down, drag off the button to release.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9578
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: MouseUp or MouseDown?

Post by dunbarx » Fri Jun 08, 2018 3:23 am

What Richard said, in terms of "normal" UI expectations. If you play around with any of your other favorite apps, you will probably see that it is "up" where the actual instant of action occurs.

But this is academic. LC offers it all, including "mouseWithin" and "mouseStillDown"

Craig Newman

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7214
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: MouseUp or MouseDown?

Post by jacque » Fri Jun 08, 2018 4:54 pm

The reason all OSs use mouseUp by default is to allow the user to cancel the button press by dragging outside the control before release. It's a handy convention when you change your mind in the middle of a click.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

RossG
Posts: 247
Joined: Thu Jan 08, 2015 7:38 am

Re: MouseUp or MouseDown?

Post by RossG » Fri Jun 08, 2018 9:38 pm

I can't recall ever changing my mind mid-click
but perhaps one day...

Don't see anything in the Dictionary about
using left or right (or middle) mouse button.
Have I missed something?
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: MouseUp or MouseDown?

Post by Klaus » Fri Jun 08, 2018 9:54 pm

RossG wrote:
Fri Jun 08, 2018 9:38 pm
Don't see anything in the Dictionary about
using left or right (or middle) mouse button.
Standard click behaviour:
Usually what we call a "simple" click is a left-click.
Right-clicks usually evokes a popup menu of some sort (context menu).
But you can of course script what you like!

If you omit the "pMouseButton" parameter i a "mouseup/down" handler then a left-click is presumed by the engine.

Parameter for "mouseup/down" handler:
1 = left click
2 = middle click, which most "mouses" do not have
3 = right-click

Examples:

Code: Select all

on mousedown pMousebutton
  if pMouseButton = 3 then
    popup btn "my popup menu" at the mouseloc
  end if
end mousedown

Code: Select all

on mouseup
  ## Same as -> on mouseup 1
  beep
end mouseup
Check the "mouseup" entry in the dictionary for more interesting stuff... 8)

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: MouseUp or MouseDown?

Post by jmburnod » Fri Jun 08, 2018 9:58 pm

Hi Ross,
There is a something about that in LC dictionary at "mouseup" entry

Edit: I tried to delete my this post with a comment "Herr Major was faster than me" and I got this message: "Sorry but you may only delete posts which have not been replied to."
Something change about delete message ?
Best regards
Jean-Marc
Last edited by jmburnod on Fri Jun 08, 2018 10:03 pm, edited 1 time in total.
https://alternatic.ch

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: MouseUp or MouseDown?

Post by FourthWorld » Fri Jun 08, 2018 9:58 pm

RossG wrote:
Fri Jun 08, 2018 9:38 pm
Don't see anything in the Dictionary about
using left or right (or middle) mouse button.
Have I missed something?
In the Dictionary entries for most mouse-related messages (mouseDown, mouseUp, mouseDoubleDown, etc.) you'll see an argument passed with the message identified as mouseButtonNumber. Just below in the "Parameters" section you'll find the discussion of how the integer passed there reflects the button number: 1 for left-click, 2 for middle-click (though not as common outside of Unix where three-button mice are the standard), and 3 for right-click.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9285
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: MouseUp or MouseDown?

Post by richmond62 » Sat Jun 09, 2018 7:36 am

I was merrily using mouseDown all the time in 2004 until Klaus
pointed out that by using mouseUp the end-user gets
a chance to change her mind by sliding her mouse pointer off the object
before releasing it.

It is also useful in this sort of scenario (pseudocode):

on mouseDown
do one action
end mouseDown

on mouseUp
perform another action
end mouseUp


and, in my case, more specifically (real code):

Code: Select all

on keyDown KD
  put (KD && "= ") into fld "fKEY"
end keyDown

on rawKeyUp RK
  put RK after fld "fKEY"
end rawKeyUp
8)

RossG
Posts: 247
Joined: Thu Jan 08, 2015 7:38 am

Re: MouseUp or MouseDown?

Post by RossG » Sat Jun 09, 2018 10:51 pm

Regarding "on mouseUp" allowing the user to
change his/her mind before releasing the
button isn't it normal for a programme to
allow the user to "undo" a wrong click?

So I find the argument for "on mouseUp" is
pretty feeble.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9578
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: MouseUp or MouseDown?

Post by dunbarx » Sun Jun 10, 2018 1:09 am

"Undo" is invaluable.

Moving the mouse off the target while still down to cancel an errant or mistaken click. priceless.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9285
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: MouseUp or MouseDown?

Post by richmond62 » Sun Jun 10, 2018 7:58 am

isn't it normal for a programme to
allow the user to "undo" a wrong click?
It should be: but I, for one, don't know how one sets up code
in LiveCode so every mouseclick is undoable after the click.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: MouseUp or MouseDown?

Post by FourthWorld » Sun Jun 10, 2018 11:50 am

richmond62 wrote:
Sun Jun 10, 2018 7:58 am
isn't it normal for a programme to
allow the user to "undo" a wrong click?
It should be: but I, for one, don't know how one sets up code
in LiveCode so every mouseclick is undoable after the click.
By using mouseUp instead of mouseDown.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9285
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: MouseUp or MouseDown?

Post by richmond62 » Sun Jun 10, 2018 3:35 pm

By using mouseUp instead of mouseDown
Really? Gosh? Wow? I would never have guessed. 8)

Some other people in this discussion seem not to have got "there" either.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7214
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: MouseUp or MouseDown?

Post by jacque » Sun Jun 10, 2018 4:27 pm

RossG wrote:
Sat Jun 09, 2018 10:51 pm
Regarding "on mouseUp" allowing the user to
change his/her mind before releasing the
button isn't it normal for a programme to
allow the user to "undo" a wrong click?

So I find the argument for "on mouseUp" is
pretty feeble.
It's actually a documented behavior in Apple's Human Interface Guidelines from back when it created the earliest personal computers, and they gave the reason as above. This was back when Apple did extensive usability testing and developed interfaces that were later copied by Microsoft and have now become the expected standard.

While experienced users may not need the behavior as much, watch any new user learning a computer for a while, or a motor-impaired user with Parkinson's or CP. Clicks and mousing are slow, and mistaken mouse movements are common. The ability to abort an unintended gesture is useful, especially if the result would be an unwanted long process or data modification.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”