set the loc of vs. move to

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Contact:

set the loc of vs. move to

Post by paulsr » Wed Oct 31, 2012 9:13 am

Now, here's something strange. At least, I think it is. Maybe someone can explain what is happening here...

I decided I wanted to provide an on-screen tutorial for an app. So I placed an arrow next to a button, and supplied some narrative to explain what a button tap would do.

Then I thought, I'll make the arrow move briefly over the button, to simulate a button tap.

Here's the arrow...

Image

And the code I used...

Code: Select all

set the loc of img tAortn to tNX,tNY
wait 20 ticks with messages
set the loc of img tAortn to tX,tY


So, the arrow moves to its new location for 20 ticks...

Image

and then moves back. The effect is quite good. This is fine, so I don't have a problem that needs to be solved, but...

I figured the movement would look smoother if I used 'move' instead of 'set the loc of'. So I changed the above code to...

Code: Select all

move img tAortn to tNX,tNY
move img tAortn to tX,tY in 20 ticks
I was right about the smoothness, but look what happens with 'move'...

Image

The arrow seems to embed itself in the button image! It's what a real arrow would do, which is kind of cute, but not what I wanted!

The arrow is not below the button image, nor on top, but stuck halfway in.

Can anyone explain this? BTW: the arrow image is the top numbered layer, so it's not going behind another layer.

Strange huh?

--paul

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: set the loc of vs. move to

Post by shaosean » Wed Oct 31, 2012 9:17 am

Is the rect of the arrow control still the same?

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Contact:

Re: set the loc of vs. move to

Post by paulsr » Wed Oct 31, 2012 9:43 am

shaosean wrote:Is the rect of the arrow control still the same?
Yes. I don't change the size, only the location of the arrow.

--paul

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: set the loc of vs. move to

Post by jmburnod » Wed Oct 31, 2012 10:16 am

Selamat Datang Paul,

Can you post the stack in attachment ?

Best regards
Jean-Marc
https://alternatic.ch

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Contact:

Re: set the loc of vs. move to

Post by paulsr » Wed Oct 31, 2012 11:18 am

I'd rather not, Jean-Marc ... it's quite large.

As I mentioned, it doesn't bother me. I don't need a solution. I just find it really bizarre.

--paul

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: set the loc of vs. move to

Post by shaosean » Wed Oct 31, 2012 11:44 am

paulsr wrote:
shaosean wrote:Is the rect of the arrow control still the same?
Yes. I don't change the size, only the location of the arrow.

--paul

You need to answer the question asked, not that question you thought was asked ;-)
After you do the move to command, is the rect still the same?

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Contact:

Re: set the loc of vs. move to

Post by paulsr » Wed Oct 31, 2012 12:16 pm

shaosean wrote:You need to answer the question asked, not that question you thought was asked ;-)
Slap on wrist. Must try harder.
shaosean wrote:After you do the move to command, is the rect still the same?
The rect before the move is 69,159,111,201 and after the first move is 53,159,95,210 because I moved the arrow 16px horizontally. After the second move, the arrow goes back to 69,159,111,201. HTH.

--paul

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: set the loc of vs. move to

Post by jacque » Wed Oct 31, 2012 5:33 pm

I've never seen that before, it is kind of cute. It looks like a redraw problem to me. What happens if you lock and unlock the screen after the move to force a redraw?

move img tAortn to tX,tY in 20 ticks
lock screen
unlock screen
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: set the loc of vs. move to

Post by shaosean » Thu Nov 01, 2012 6:33 am

paulsr wrote:Slap on wrist. Must try harder.
yes ;-)
shaosean wrote:The rect before the move is 69,159,111,201 and after the first move is 53,159,95,210 because I moved the arrow 16px horizontally. After the second move, the arrow goes back to 69,159,111,201. HTH.
k.. everything seems to be fine there, so it seems like a weird redraw issue as jacque mentioned..

Code: Select all

move command
lock screen
unlock screen

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Contact:

Re: set the loc of vs. move to

Post by paulsr » Thu Nov 01, 2012 7:36 am

jacque wrote:I've never seen that before, it is kind of cute. It looks like a redraw problem to me. What happens if you lock and unlock the screen after the move to force a redraw?

move img tAortn to tX,tY in 20 ticks
lock screen
unlock screen
Makes no difference Jacqueline.

Just to test, I tried moving the arrow to a different place on the card, where there are no underlying images except for the background. Now I can see better what is happening. If I move the arrow 16px to the left, the 16 left-most pixels of the image disappear ... and return, when I move the image back to its original position.

So the button image is a red herring. The arrow is not really embedding itself in the button :) it's just partly disappearing!

--paul

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: set the loc of vs. move to

Post by shaosean » Thu Nov 01, 2012 9:24 am

What about using the relative form of the move command?

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Contact:

Re: set the loc of vs. move to

Post by paulsr » Thu Nov 01, 2012 10:51 am

Okay, mystery solved!

I've just realized that the arrow, which is 42x42 is inside a group which is 50x50. If part of the arrow "moves" outside the boundary of the group it becomes invisible. Whereas if I "set the location of" the arrow it doesn't seem to matter if part of the arrow is outside the group.

To which you will probably all say "We knew that!" :oops:

--paul

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: set the loc of vs. move to

Post by shaosean » Thu Nov 01, 2012 1:08 pm

Had there been a mention of it being grouped, we would have said that ;-)

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: set the loc of vs. move to

Post by jacque » Thu Nov 01, 2012 7:12 pm

Essential info. :) You can use the move command if you move the group instead of a single image. Or, set the lockloc of the group to false and move only the arrow. Without being locked, the group will expand automatically to show its entire content.

If your group is already unlocked then I'm at a loss why setting the location is different than moving. They should be the same. See "boundingRect" in the dictionary though, it may be that the group's boundingRect is not empty, which will prevent it from expanding.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Contact:

Re: set the loc of vs. move to

Post by paulsr » Fri Nov 02, 2012 5:40 am

shaosean wrote:Had there been a mention of it being grouped, we would have said that ;-)
Yeah, I'm sorry about that. I had completely forgotten the arrow image was in a group.

--paul

Post Reply