Handling mouseText and mouseline events

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
glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Handling mouseText and mouseline events

Post by glenn9 » Mon Nov 30, 2020 10:22 am

Hi everyone,

If in a field containing various lengths of lines of text the mouseText isn't handleable but a mouseLine is, is it possible to handle both of these commands in the same mouseUp event?

My tries so far seem to have shown me that to handle a mouseText event the listBehavior of the field needs to be 'false', and 'true' for the mouseLine command.

In the same mouseUp event I've tried to set the listBehavior with script to be concordant with the relevent mouseText/Line test but with only limited success.

Just wanted to check if what I'm wanting to achieve is possible??

Thanks,

Glenn

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Handling mouseText and mouseline events

Post by richmond62 » Mon Nov 30, 2020 2:48 pm

All seems fairly straightforward:

Code: Select all

on mouseUp
   put the mouseText into fld "Lclicked"
   put the mouseLine into fld "Lnum"
end mouseUp
-
Screenshot 2020-11-30 at 15.46.11.png
-
Screenshot 2020-11-30 at 15.48.49.png
Attachments
Line Indicator.livecode.zip
Here's the stack.
(1.03 KiB) Downloaded 199 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Handling mouseText and mouseline events

Post by richmond62 » Mon Nov 30, 2020 2:53 pm

Screenshot 2020-11-30 at 15.52.47.png
-
Changing the line contents to be of varying lengths seems to make no obvious difference.

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Handling mouseText and mouseline events

Post by Klaus » Mon Nov 30, 2020 2:59 pm

Hi Glenn,

of coursee you can use mousetext and mouseline in ONE mouseup handler.

BUT an open field (locktext = false) does not receive any MOUSEUP or MOUSEDOWN* messages!
*Only a right mousedown to be able to display a context menu or whatever.
Something like this does work:

Code: Select all

on mousedown tNumber
  ## Right mousedown
  if tNumvber = 3 then
    popup btn "some text related menu" at the mouseloc
 end if
end mousedown
But NO mouseup handler.

A "mousemove" handler does work however in open fields, no idea if this will help you.

Code: Select all

on mousemove
  put the mousetext & CR & the mouseline
end mousemove
So maybe you need to rethink what and how you are doing what you need to.


Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Handling mouseText and mouseline events

Post by dunbarx » Mon Nov 30, 2020 4:36 pm

THIS CALLS FOR A KLUDGE!

If your field is editable, put this in the field script:

Code: Select all

on mouseEnter
  interrogate
end mouseEnter

on interrogate
  if the mouse is down and the mouseLoc is within the rect of me then answer the mouseLine & return & the mousetext
  send "interrogate" to me in 1
end interrogate
Works a treat. Have not tested to see if any special escape routes are a good idea.
The one embedded, "...and the mouseLoc is within..." is VERY necessary.
Craig

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Re: Handling mouseText and mouseline events

Post by glenn9 » Mon Nov 30, 2020 5:16 pm

Dear all,

many thanks for the suggestions, I'll gives these a try and see how it goes...

regards,

Glenn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Handling mouseText and mouseline events

Post by dunbarx » Mon Nov 30, 2020 5:34 pm

Hi.

Let us know how it goes. My post allows you to click any number of times in the field, each time giving you information. If you want to do this only once, change the handler to:

Code: Select all

on mouseEnter
 interrogate
end mouseEnter

on interrogate
  if the mouse is down and the mouseLoc is within the rect of me then
     answer the mouseLine & return & the mousetext
     exit to top
  end if
  send "interrogate" to me in 1
end interrogate
Craig

Post Reply