Method question

Glen Bojsza gbojsza at gmail.com
Tue Nov 9 15:33:31 EST 2010


Yes this works correctly. Also, I took Peter's solution and found that
starting a mouseUp outside the graphic does not report anything because the
graphic has it's own mouseUp (and viceversa with mouseDown).

The fix for this is to do a mouseUp and mouseDown for the card and determine
if the mouseloc is within the graphic.

So both solutions are applicable and different in their approach.

I will expand on this to make a "zoom" feature for the graphing packages
allowing my end user to easily "zoom" into data graphs they have interest
in.

All the best!

Glen

On Tue, Nov 9, 2010 at 1:20 PM, Phil Davis <revdev at pdslabs.net> wrote:

> Ah! I overlooked that. Here's a fix:
>
>
> -- card script --
>
> local h1, h2, v1, v2, wasWithinGrc
>
>
> on mouseDown
>   put false into wasWithinGrc
>
>   put the clickH into h1
>   put the clickV into v1
> end mouseDown
>
>
> on mouseMove h,v
>   if h,v is within the rect of grc 1
>   then put true into wasWithinGrc
> end mouseMove
>
>
> on mouseUp
>   -- exit if mouse never entered the grc
>   if wasWithinGrc = true then
>
>      put the mouseH into h2
>      put the mouseV into v2
>      put grcDragRegion()
>   else
>      put empty
>   end if
>
> end mouseUp
>
>
> function grcDragRegion
>   -- define mouse drag rect
>   put min(h1,h2) into tMouseLeft
>   put max(h1,h2) into tMouseRight
>   put min(v1,v2) into tMouseTop
>   put max(v1,v2) into tMouseBottom
>
>   -- define overlap of mouse drag rect & grc rect
>   put max(tMouseLeft, the left of grc 1) into item 1 of tOverlapRect
>   put max(tMouseTop, the top of grc 1) into item 2 of tOverlapRect
>   put min(tMouseRight, the right of grc 1) into item 3 of tOverlapRect
>   put min(tMouseBottom, the bottom of grc 1) into item 4 of tOverlapRect
>
>   -- return it
>   return tOverlapRect
> end grcDragRegion
>
>
>
> On 11/9/10 11:57 AM, Glen Bojsza wrote:
>
>> Hi Phil,
>>
>> Yes it works BUT it doesn't constrain itself to the graphic.
>>
>> I want it to only to report the points if the user includes the graphic
>> when
>> they d their drag... as it currently stands it reports coordinates even if
>> the user does not drag across the graphic.
>>
>> But other that that it is total a different perspective on how I was
>> looking
>> at the problem... I was too focused on the graphic.
>>
>> thanks,
>>
>> Glen
>>
>> On Tue, Nov 9, 2010 at 12:27 PM, Phil Davis<revdev at pdslabs.net>  wrote:
>>
>>  Hi Glen,
>>>
>>> See if this works:
>>>
>>>
>>> -- card script --
>>>
>>> local h1, h2, v1, v2
>>>
>>>
>>> on mouseDown
>>>   put the clickH into h1
>>>   put the clickV into v1
>>> end mouseDown
>>>
>>>
>>> on mouseUp
>>>   put the mouseH into h2
>>>   put the mouseV into v2
>>>   put grcDragRegion()
>>> end mouseUp
>>>
>>>
>>> function grcDragRegion
>>>   -- define mouse drag rect
>>>   put min(h1,h2) into tMouseLeft
>>>   put max(h1,h2) into tMouseRight
>>>   put min(v1,v2) into tMouseTop
>>>   put max(v1,v2) into tMouseBottom
>>>
>>>   -- define overlap of mouse drag rect&  grc rect
>>>   put max(tMouseLeft, the left of grc 1) into item 1 of tOverlapRect
>>>   put max(tMouseTop, the top of grc 1) into item 2 of tOverlapRect
>>>   put min(tMouseRight, the right of grc 1) into item 3 of tOverlapRect
>>>   put min(tMouseBottom, the bottom of grc 1) into item 4 of tOverlapRect
>>>
>>>   -- return it
>>>   return tOverlapRect
>>> end grcDragRegion
>>>
>>> Phil Davis
>>>
>>>
>>>
>>> On 11/9/10 10:48 AM, Glen Bojsza wrote:
>>>
>>>  I have a problem which I am not certain which method is valid or should
>>>> be
>>>> used (with Rev / Livecode there are sometimes too many ways of achieving
>>>> a
>>>> goal).
>>>>
>>>> I have a graphic on a card left 62 right 462.
>>>>
>>>> My objective is to allow a user to left click and drag across the
>>>> graphic
>>>> as
>>>> if selecting a section of it.
>>>>
>>>> I need start left,top,right,bottom and end left,top,right,bottom.
>>>>
>>>> The only interest is knowing the start of the drag when inside the
>>>> graphic
>>>> and the end of the drag inside the graphic... with the following
>>>> caveats.
>>>>
>>>>
>>>>    - The user may start the drag either outside the graphic and then
>>>>    continue the drag into the graphic (which is the start point) or
>>>> start
>>>> the
>>>>    drag inside the graphic which would be the start point.
>>>>    - The user may release the mouse button inside the graphic which
>>>>    indicates the stop point or release the mouse button outside the
>>>> graphic
>>>>    where the stop point is at the point of the mouse leaving the
>>>> graphic.
>>>>
>>>>
>>>> This seems like it should be simple but I am getting tied down but
>>>> trying
>>>> to
>>>> over complicate it?
>>>>
>>>> This is for Windows and Linux .
>>>>
>>>> Any elegant or simple solutions out there?
>>>> _______________________________________________
>>>> use-revolution mailing list
>>>> use-revolution at lists.runrev.com
>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>> subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>>>
>>>>
>>>>  --
>>> Phil Davis
>>>
>>> PDS Labs
>>> Professional Software Development
>>> http://pdslabs.net
>>>
>>> _______________________________________________
>>> use-revolution mailing list
>>> use-revolution at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>>
>>>  _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>
>>
> --
> Phil Davis
>
> PDS Labs
> Professional Software Development
> http://pdslabs.net
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



More information about the use-livecode mailing list