Preventing control selection

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

Preventing control selection

Post by dunbarx » Tue Mar 30, 2021 10:50 pm

With the pointer tool chosen, I wanted to prevent controls from being selected, either by clicking on or dragging across those controls.

The only "ordinary" messages sent with the pointer tool are "mouseEnter", "mouseLeave" and "mouseDoubleDown" There is a message "objectSelectionStarted" (and "...ended"), and if I put this in the card script:

Code: Select all

on objectSelectionStarted
select empty
end objectSelectionStarted
It works for dragging across a control, but only for the first one encountered. The handler cannot be placed in a control script. And anyway it does nothing for clicking on a control.

I would love this, as I am fiddling around within a very dense collection of controls, and it is hard to select only certain ones amongst the others.

Any ideas?

Craig

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

Re: Preventing control selection

Post by Klaus » Wed Mar 31, 2021 9:13 am

Hi Craig,

the only way I know to do this is to:

Code: Select all

set the cantmodify of stack "your stack here" to TRUE
There is no way to set this via the inspector, so you need to do this
in a button or the message box.

Best

Klaus

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

Re: Preventing control selection

Post by jmburnod » Wed Mar 31, 2021 9:58 am

Does cantselect could be usefull ?
After Klaus's post I feel i dont understand the goal :oops:
Jean-Marc
https://alternatic.ch

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

Re: Preventing control selection

Post by Klaus » Wed Mar 31, 2021 10:34 am

Oh, yes, we also have the "cantselect" property. :D
So if you only want SOME of your controls to be not selectable, set that property of them.

SparkOut
Posts: 2834
Joined: Sun Sep 23, 2007 4:58 pm

Re: Preventing control selection

Post by SparkOut » Wed Mar 31, 2021 11:22 am

This assumes that you have a convenient way of selecting which objects are and aren't selectable by script. So you might as well script the selection of the object you want to edit.
Maybe you could set the scalefactor of the stack to make the display easier to navigate around for mouse selection?

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

Re: Preventing control selection

Post by dunbarx » Wed Mar 31, 2021 7:00 pm

CantSelect certainly would work, but it requires that property to be preset in certain controls, and that I write a handler each time I want to do this for the different controls I want to select. I have a card crammed with tightly packed graphics and fields.

I did not explain this well enough. I want to do this on the fly, so I made this to use the optionKey to select only certain controls while dragging across the card.

Code: Select all

local tList
on mouseEnter
   if "card" is in the name of the target then exit to top --don't select the card
   if the optionKey is down  then 
      put " and" &&  the abbrev ID of the target && "and" after tList
      
      if "and" = word 1 of tList then delete word 1 of tList
      if "and" = the last word of tList then delete the last word of tList
      do "select" && tList
   end if
end mouseEnter
This works regardless of which tool is selected. I think it can be made more elegant, losing those two annoying "delete" lines.

Craig

EDIT: Forgot to declare the variable tList as local. And one needs to clear that variable now and then.

Post Reply

Return to “Talking LiveCode”