Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Wrong Canvas.MouseUp Event? (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: [Semi-OT] Messages not getting into archive
Next thread: Checking if speech finished?


Encodings, Trademarks, Files, and POSIX   -   Rubber Chicken Software Co.
  Wrong Canvas.MouseUp Event?   -   Tom
   Re: Wrong Canvas.MouseUp Event?   -   Greg O'Lone
   Re: Wrong Canvas.MouseUp Event?   -   Jim Dossey
    Re: Wrong Canvas.MouseUp Event?   -   Tom
   Re: Wrong Canvas.MouseUp Event?   -   Charles Yeomans
    Re: Wrong Canvas.MouseUp Event?   -   Tom
   Re: Wrong Canvas.MouseUp Event?   -   Joe Huber
    Re: Wrong Canvas.MouseUp Event?   -   Joe Strout
   Re: Wrong Canvas.MouseUp Event?   -   Tim Jones
   Re: Wrong Canvas.MouseUp Event?   -   Charles Yeomans
    Re: Wrong Canvas.MouseUp Event?   -   Tom
   Re: Wrong Canvas.MouseUp Event?   -   Ron Benditt

Wrong Canvas.MouseUp Event?
Date: 30.04.09 10:34 (Thu, 30 Apr 2009 11:34:21 +0200)
From: Tom
Hi List!

The Language reference states:
> Canvas.MouseUp Event:
> The mouse button was released inside the Canvas region at the location
> passed in to x,y.

But the event also occurs when the mouse is released _ouside_ of the
canvas!

To reproduce this:
make a new project and put a canvas and an Editfield on the Window. Make
the EditField multiline.
In the Canvas events add following code
> Sub Paint(g As Graphics)
> g.ForeColor = &cFFAB60
> g.FillRect 0,0,me.Width, me.Height
> End Sub
>
> Function MouseDown(X As Integer, Y As Integer) As Boolean
> EditField1.AppendText "MouseDown, x=" + str(x) + ", y=" +
> str(y)+ EndOfLine
> return true
> End Function
>
> Sub MouseUp(X As Integer, Y As Integer)
> EditField1.AppendText "MouseUp, x=" + str(x) + ", y=" +
> str(y)+ EndOfLine
> End Sub

Now click the canvas and drag the mouse outside of it. Then release the
mouse key.
I think there should be no MouseUp Event because the mouse is not
released _inside_ of the Canvas area.
Tested on Mac and Win XP.

This looks like a bug for me. Comments please.

Cheers,

Tom

PS. RB 2009r2 on Mac OS X 10.5.6

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Wrong Canvas.MouseUp Event?
Date: 30.04.09 12:58 (Thu, 30 Apr 2009 07:58:24 -0400)
From: Greg O'Lone
On Apr 30, 2009, at 5:34 am, Tom wrote:

> Hi List!
>
> The Language reference states:
>> Canvas.MouseUp Event:
>> The mouse button was released inside the Canvas region at the
>> location passed in to x,y.
>
> But the event also occurs when the mouse is released _ouside_ of the
> canvas!
>
> To reproduce this:
> make a new project and put a canvas and an Editfield on the Window.
> Make the EditField multiline.
> In the Canvas events add following code
>> Sub Paint(g As Graphics)
>> g.ForeColor = &cFFAB60
>> g.FillRect 0,0,me.Width, me.Height
>> End Sub
>>
>> Function MouseDown(X As Integer, Y As Integer) As Boolean
>> EditField1.AppendText "MouseDown, x=" + str(x) + ", y=" +
>> str(y)+ EndOfLine
>> return true
>> End Function
>>
>> Sub MouseUp(X As Integer, Y As Integer)
>> EditField1.AppendText "MouseUp, x=" + str(x) + ", y=" +
>> str(y)+ EndOfLine End Sub
>
> Now click the canvas and drag the mouse outside of it. Then release
> the mouse key.
> I think there should be no MouseUp Event because the mouse is not
> released _inside_ of the Canvas area.
> Tested on Mac and Win XP.
>
> This looks like a bug for me. Comments please.

I can see how this might be seen as a bug, but it could be helpful if
you're doing custom drag/drop coding, Not that I have, since I
expected it to work as documented.

Greg O'Lone
Stretched Out Software
--------------------------
Excellence Through Innovation

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Wrong Canvas.MouseUp Event?
Date: 30.04.09 13:04 (Thu, 30 Apr 2009 08:04:42 -0400)
From: Jim Dossey
On Thu, Apr 30, 2009 at 5:34 AM, Tom <<email address removed>> wrote:

> Hi List!
>
> The Language reference states:
>
>> Canvas.MouseUp Event:
>> The mouse button was released inside the Canvas region at the location
>> passed in to x,y.
>>
> But the event also occurs when the mouse is released _ouside_ of the
> canvas!
>
> To reproduce this:
> make a new project and put a canvas and an Editfield on the Window. Make
> the EditField multiline.
> In the Canvas events add following code
>
>> Sub Paint(g As Graphics)
>> g.ForeColor = &cFFAB60
>> g.FillRect 0,0,me.Width, me.Height
>> End Sub
>>
>> Function MouseDown(X As Integer, Y As Integer) As Boolean
>> EditField1.AppendText "MouseDown, x=" + str(x) + ", y=" + str(y)+
>> EndOfLine
>> return true
>> End Function
>>
>> Sub MouseUp(X As Integer, Y As Integer)
>> EditField1.AppendText "MouseUp, x=" + str(x) + ", y=" + str(y)+
>> EndOfLine End Sub
>>
> Now click the canvas and drag the mouse outside of it. Then release the
> mouse key.
> I think there should be no MouseUp Event because the mouse is not released
> _inside_ of the Canvas area.
> Tested on Mac and Win XP.
>
> This looks like a bug for me. Comments please.

I don't see this as a bug. For example, a user might click on a control and
then realize that was a mistake. So they move the mouse out of the control
before releasing the button. By checking the X,Y coordinates you can see
what the user did and take the appropriate action. There are probably other
much better reasons for having mouseup events outside of the control.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Wrong Canvas.MouseUp Event?
Date: 30.04.09 13:35 (Thu, 30 Apr 2009 14:35:25 +0200)
From: Tom
Jim Dossey wrote:
>> The Language reference states:
>>
>>> Canvas.MouseUp Event:
>>> The mouse button was released inside the Canvas region at the location passed in to x,y.
>>>
> I don't see this as a bug. For example, a user might click on a
> control and ,then realize that was a mistake. So they move the mouse
> out of the control before releasing the button. By checking the X,Y
> coordinates you can see what the user did and take the appropriate
> action. There are probably other much better reasons for having
> mouseup events outside of the control.

That is exactly what I do now, but from the Language reference there
should be no need for checking when the MouseUp event only occurs when
the mouse is inside the canvas region.

Cheers,

Tom

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Wrong Canvas.MouseUp Event?
Date: 30.04.09 14:18 (Thu, 30 Apr 2009 09:18:12 -0400)
From: Charles Yeomans

On Apr 30, 2009, at 5:34 AM, Tom wrote:

> Hi List!
>
> The Language reference states:
>> Canvas.MouseUp Event:
>> The mouse button was released inside the Canvas region at the
>> location passed in to x,y.
>
> But the event also occurs when the mouse is released _ouside_ of the
> canvas!
>
> To reproduce this:
> make a new project and put a canvas and an Editfield on the Window.
> Make the EditField multiline.
> In the Canvas events add following code
>> Sub Paint(g As Graphics)
>> g.ForeColor = &cFFAB60
>> g.FillRect 0,0,me.Width, me.Height
>> End Sub
>>
>> Function MouseDown(X As Integer, Y As Integer) As Boolean
>> EditField1.AppendText "MouseDown, x=" + str(x) + ", y=" +
>> str(y)+ EndOfLine
>> return true
>> End Function
>>
>> Sub MouseUp(X As Integer, Y As Integer)
>> EditField1.AppendText "MouseUp, x=" + str(x) + ", y=" +
>> str(y)+ EndOfLine End Sub
>
> Now click the canvas and drag the mouse outside of it. Then release
> the mouse key.
> I think there should be no MouseUp Event because the mouse is not
> released _inside_ of the Canvas area.
> Tested on Mac and Win XP.
>
> This looks like a bug for me. Comments please.

The behavior as you see it has been so as long as I can remember. But
the documentation for the current version of REALbasic states

"The mouse button was released inside the Canvas region at the
location passed in to x,y"

I suggest that you file a feedback report.

Charles Yeomans




_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Wrong Canvas.MouseUp Event?
Date: 30.04.09 14:53 (Thu, 30 Apr 2009 15:53:01 +0200)
From: Tom
Charles Yeomans wrote:
> The behavior as you see it has been so as long as I can remember. But
> the documentation for the current version of REALbasic states
>
> "The mouse button was released inside the Canvas region at the
> location passed in to x,y"
>
> I suggest that you file a feedback report.

Thanks for the info. I wrote a bug report abut this.

I understand the the MouseUp outside of the canvas is helpful for drag &
drop but for a custom button it makes more work because you need to
check the x/y-position of the MouseUp event.
Perhaps it would be helpful to make the behavior optional...

I look forward to RS response. The bug is "Case 7521".

Cheers,

Tom

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Wrong Canvas.MouseUp Event?
Date: 30.04.09 15:13 (Thu, 30 Apr 2009 07:13:28 -0700)
From: Joe Huber
At 11:34 AM +0200 4/30/09, Tom wrote:
>Now click the canvas and drag the mouse outside of it. Then release
>the mouse key.
>I think there should be no MouseUp Event because the mouse is not
>released _inside_ of the Canvas area.
>Tested on Mac and Win XP.
>
>This looks like a bug for me. Comments please.

IMHO The current behavior is the most flexible. It allows you to
easily detect a mouse up either within or outside the canvas. Since
it has behaved this way for so long and since it's the most flexible
approach, I'd suggest that the docs be changed to reflect the actual
behavior.

IMHO It's only a bug with the documentation.

Best regards,
Joe Huber

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Wrong Canvas.MouseUp Event?
Date: 30.04.09 15:37 (Thu, 30 Apr 2009 08:37:59 -0600)
From: Joe Strout
Joe Huber wrote:

>> Now click the canvas and drag the mouse outside of it. Then release
>> the mouse key.
>> I think there should be no MouseUp Event because the mouse is not
>> released _inside_ of the Canvas area.
>> Tested on Mac and Win XP.
>>
>> This looks like a bug for me. Comments please.
>
> IMHO The current behavior is the most flexible. It allows you to easily
> detect a mouse up either within or outside the canvas. Since it has
> behaved this way for so long and since it's the most flexible approach,
> I'd suggest that the docs be changed to reflect the actual behavior.
>
> IMHO It's only a bug with the documentation.

I strongly agree. In typical usage, you change state on MouseDown --
you're in some mouse-tracking state (making a selection ring, dragging
an object, whatever). MouseUp is where you leave that state, and it's
important to do that, regardless of whether the mouse is inside or
outside the control at that point. If you want to take different
behavior depending on whether the mouse is inside or outside, well,
that's very easy to test.

Best,
- Joe

Re: Wrong Canvas.MouseUp Event?
Date: 30.04.09 15:15 (Thu, 30 Apr 2009 07:15:17 -0700)
From: Tim Jones
On Apr 30, 2009, at 6:53 AM, Tom wrote:

> Charles Yeomans wrote:
>> The behavior as you see it has been so as long as I can remember.
>> But the documentation for the current version of REALbasic states
>>
>> "The mouse button was released inside the Canvas region at the
>> location passed in to x,y"
>>
>> I suggest that you file a feedback report.
>
> Thanks for the info. I wrote a bug report abut this.
>
> I understand the the MouseUp outside of the canvas is helpful for
> drag & drop but for a custom button it makes more work because you
> need to check the x/y-position of the MouseUp event.
> Perhaps it would be helpful to make the behavior optional...

I also feel that we should get a MouseExit event if the mouse is
moved out of the canvas while the button is down. That would make
tracking this situation even easier. I know this was requested back
in the old bug database, but the Carbon blocking event model on
MouseDown prevented it from being instituted.

I've always used the X/Y check in the MouseUp event to make sure the
event occurred within the Canvas.

If X > Me.Left And (X < Me.Left + Me.Width) And Y > Me.Top And (Y <
Me.Top + Me.Height) Then
// do mouseup action
End If

Tim

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Wrong Canvas.MouseUp Event?
Date: 30.04.09 15:56 (Thu, 30 Apr 2009 10:56:49 -0400)
From: Charles Yeomans

On Apr 30, 2009, at 9:53 AM, Tom wrote:

> Charles Yeomans wrote:
>> The behavior as you see it has been so as long as I can remember.
>> But the documentation for the current version of REALbasic states
>>
>> "The mouse button was released inside the Canvas region at the
>> location passed in to x,y"
>>
>> I suggest that you file a feedback report.
>
> Thanks for the info. I wrote a bug report abut this.
>
> I understand the the MouseUp outside of the canvas is helpful for
> drag & drop but for a custom button it makes more work because you
> need to check the x/y-position of the MouseUp event.
> Perhaps it would be helpful to make the behavior optional...
>
> I look forward to RS response. The bug is "Case 7521".

Such optional behavior almost always proves to be an annoyance for
me. Instead, I suggest that you use this method.

Function IsMouseOver(X as Integer, Y as Integer) as Integer
return (X >= 0) and (X < me.Left) and (Y >= 0) and (Y < me.Height)
End Function

Either add it to your custom button classes, as I do, or add it to all
Canvas objects as an extension method.

Function IsMouseOver(extends c as Canvas, X as Integer, Y as Integer)
as Integer
return (X >= 0) and (X < c.Left) and (Y >= 0) and (Y < c.Height)
End Function

Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Wrong Canvas.MouseUp Event?
Date: 30.04.09 16:11 (Thu, 30 Apr 2009 17:11:16 +0200)
From: Tom
Charles Yeomans wrote:
> Such optional behavior almost always proves to be an annoyance for me.

I agree. So they should just change the documentation.

> Instead, I suggest that you use this method.
>
> Function IsMouseOver(X as Integer, Y as Integer) as Integer
> return (X >= 0) and (X < me.Left) and (Y >= 0) and (Y < me.Height)
> End Function
>
> Either add it to your custom button classes, as I do, or add it to all
> Canvas objects as an extension method.
>
> Function IsMouseOver(extends c as Canvas, X as Integer, Y as Integer)
> as Integer
> return (X >= 0) and (X < c.Left) and (Y >= 0) and (Y < c.Height)
> End Function

I did that already ;)

Cheers,

Tom

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Wrong Canvas.MouseUp Event?
Date: 30.04.09 15:42 (Thu, 30 Apr 2009 07:42:39 -0700)
From: Ron Benditt
> But the event also occurs when the mouse is released _ouside_ of the
> canvas!

Yes, I've seen this too. For me, it was actually helpful... but I
really didn't expect it and I can see why it may be considered a bug.

I've done some iPhone programming with XCode and they have separate
events depending on where the mouse-up has occurred (or in the iPhone-
case, "finger-up"!). It seems to me that RB really could use another
event... one for a mouse-up inside of the canvas and one for a mouse-
up outside (when the mouse-down was instantiated inside the canvas).

Regards,

Ron Benditt
Alien Apparatus Company, Inc.
http://www.alienapparatus.com

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>