Is a selection rectangle possible?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 50
- Joined: Mon Apr 03, 2017 3:55 pm
Is a selection rectangle possible?
I'm curious to know if anyone's been able to simulate a selection rectangle where multiple objects can be selected as long as they're within or touching the selection bounds, even if they've never been touched by the mouseLoc. I know about selectionMode with the pointer tool, but I'm wondering about something that would work in browse mode.
Hypertalk developer on and off since the days of SuperCard. Currently using LC to do rapid prototyping for a new kids' toy.
Re: Is a selection rectangle possible?
Hi.
Maybe something like:
Craig
Maybe something like:
Code: Select all
on mouseUp
ask "Select rectangle"
--repeat with y = 1 to the number of controls
-- if the left of control y >= item 1 of it and the right of control y <= item 3 of it and\
--the top of control y >= item 2 of it and the bottom of control y <= item 4 of it then put y & return after accum
-- end repeat
--repeat with y = 1 to the number of lines of accum
--select each control from that list
choose pointer tool
drag from item 1 to 2 of it to item 3 to 4 of it
end mouseUp
Last edited by dunbarx on Thu Nov 17, 2022 7:40 pm, edited 1 time in total.
Re: Is a selection rectangle possible?
I first though of collecting the several controls that fall within the bounds of the chosen rect, and selecting them all in turn.That is what is going on in that repeat loop.
But it seems like only the last one on such a list actually remains selected. So the best method is to change tools and simulate a drag over the chosen bounds. You only need to:
Craig
But it seems like only the last one on such a list actually remains selected. So the best method is to change tools and simulate a drag over the chosen bounds. You only need to:
Code: Select all
on mouseUp
ask "Select rectangle"
choose pointer tool
drag from item 1 to 2 of it to item 3 to 4 of it
end mouseUp
Last edited by dunbarx on Thu Nov 17, 2022 7:39 pm, edited 4 times in total.
Re: Is a selection rectangle possible?
Did you want to actually "see" a selection rectangle? That is simple as well, but only lagniappe.
Craig
Craig
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Is a selection rectangle possible?
Your can emulate the built-in Pointer tool, and I've had to do it on occasion. But it always feels like I'm cheating myself to spend time emulating a built-in feature.
Are you in a position to describe what you're working on and how the emulated Pointer tool fits in?
Sometimes there's a way to use the Pointer tool directly, without emulating it, and still keep all the advantages of the Browse tool where that different mode is needed.
Are you in a position to describe what you're working on and how the emulated Pointer tool fits in?
Sometimes there's a way to use the Pointer tool directly, without emulating it, and still keep all the advantages of the Browse tool where that different mode is needed.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Is a selection rectangle possible?
@Richard.
@ M-A Kuttner
I assume you know that the ask dialog expects four integers separated by commas, and that they make sense in terms of a real rect.
Another thing, that touches on Richard's post, is to have that pointer tool actually drag at a rate that is visible to the user. In that way the selection rectangle that it natively shows when done by hand would, er, show. With my handler, it all happens so fast that you cannot see it. I am not sure how to do this just now, since the drag command has no rate parameter similar to, say, the move command.
To further kludge this, assuming you need it, is to create, say, a transparent graphic with a dashed border. You can resize it from the topRight to the bottomLeft at any rate you like, and you already have the data needed to select the controls within.
What do you think?
Craig
Like I did?Your can emulate the built-in Pointer tool,

@ M-A Kuttner
I assume you know that the ask dialog expects four integers separated by commas, and that they make sense in terms of a real rect.
Another thing, that touches on Richard's post, is to have that pointer tool actually drag at a rate that is visible to the user. In that way the selection rectangle that it natively shows when done by hand would, er, show. With my handler, it all happens so fast that you cannot see it. I am not sure how to do this just now, since the drag command has no rate parameter similar to, say, the move command.
To further kludge this, assuming you need it, is to create, say, a transparent graphic with a dashed border. You can resize it from the topRight to the bottomLeft at any rate you like, and you already have the data needed to select the controls within.
What do you think?
Craig
Last edited by dunbarx on Thu Nov 17, 2022 8:04 pm, edited 2 times in total.
Re: Is a selection rectangle possible?
Klaus.
Norwegian???
I means something added as a bonus, but not really important to the thing in question.
This is mainly heard in New Orleans, where it might be literally eaten as icing on a Beignet.
How are you with Beignet?
Craig
Norwegian???
I means something added as a bonus, but not really important to the thing in question.
This is mainly heard in New Orleans, where it might be literally eaten as icing on a Beignet.
How are you with Beignet?


Craig
Re: Is a selection rectangle possible?
Yep, Norwegian, see screenshot...
OK, thanks!
"Beignet" is a pastry, right?
OK, thanks!

"Beignet" is a pastry, right?
Re: Is a selection rectangle possible?
I just remembered the property "dragSpeed" Watch this space...
Craig
Craig
Last edited by dunbarx on Thu Nov 17, 2022 8:16 pm, edited 1 time in total.
Re: Is a selection rectangle possible?
HA!
HA!!
Craig
Code: Select all
on mouseUp
ask "Select rectangle" with "100,100,300,300"
choose pointer tool
set the dragSpeed to 400
drag from item 1 to 2 of it to item 3 to 4 of it
end mouseUp
Craig
Re: Is a selection rectangle possible?
Klaus.
It is very similar to an Italian "Zeppole". In the US, such a thing (fried dough, really) is best with confectioners sugar ALL over it. You know, lagniappe.
Craig
Sort of."Beignet" is a pastry, right?
It is very similar to an Italian "Zeppole". In the US, such a thing (fried dough, really) is best with confectioners sugar ALL over it. You know, lagniappe.
Craig
-
- Posts: 50
- Joined: Mon Apr 03, 2017 3:55 pm
Re: Is a selection rectangle possible?
Thanks guys! The project is that I have a large field of small rectangle graphics butted up against one another, and I want to select any subset of them within the larger field so as to access the names of each. However, I don't want to reposition any of them.
As for Beignets, I got a chance to have some in New Orleans one evening when I visited, along with that great coffee. Mmmm...
As for Beignets, I got a chance to have some in New Orleans one evening when I visited, along with that great coffee. Mmmm...
Hypertalk developer on and off since the days of SuperCard. Currently using LC to do rapid prototyping for a new kids' toy.
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Is a selection rectangle possible?
Maybe I misread that, but it looked like you used the built-in Pointer tool, emulating the user's gesture to drag the selection.
I had the impression that the OP was looking to provide an interactive experience similar to the pointer tool, but using the Browse tool. I may have misunderstood his request. I look forward to his return to clarify.
If the goal is to demonstrate a user-like behavior using the built-in tools, your method is a good one. But if the goal is to select objects, one can just set the selected property of objects within the loop directly, using whatever logical or spatial criteria is needed.
Providing interactive Pointer tool behavior with the Browse tool is doable, but complicated. One of the many godsends of tools like SuperCard and LiveCode is that we have a Pointer tool at the ready. Emulating it requires making and managing some form of selection bounds indicator, tracking mouseMove to check intersection of objects, and creating some form of indicator for each object to reflect the selected state. I've had to do that before, as have Ken Ray and others, but it was a lot of work for the engine team to build in, and is a lot of work for a scripter to reproduce.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn