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
-
Samuele
- Posts: 282
- Joined: Mon Oct 11, 2021 7:05 pm
Post
by Samuele » Wed May 25, 2022 4:42 pm
Hi, I'm trying to shrink a button when the user clicks on it but the button will remain at the same place as before, I wrote some lines and on the pc they work perfectly
Code: Select all
local tmyWidth
local tmyHeight
local sX
local sY
on mouseDown
put the location of me into tMyLocation
put item 1 of tMyLocation into sX
put item 2 of tMyLocation into sY
put the width of me into tmyWidth
put the height of me into tmyHeight
set the width of me to (tmyWidth / 1.1)
set the height of me to (tmyHeight / 1.1)
set the location of me to sX, sY
send mouseUp to me in 3 seconds
end mouseDown
on mouseUp
set the width of me to tmyWidth
set the height of me to tmyHeight
set the location of me to sX, sY
end mouseUp
but on mobile you can see that the button shrinks before and then afterwards it returns to the same location and it is not pretty at all, is there maybe another way to make this happen that hopefully will work also for mobile?
Thanks!
-
Attachments
-
- ShrinkCenter.zip
- (20.45 KiB) Downloaded 139 times
Samuele.
-
richmond62
- Livecode Opensource Backer

- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Post
by richmond62 » Wed May 25, 2022 7:34 pm
Fancy meeting you again. . .
-
I must be a simple soul, for the reason that I always find your scripts very difficult
to understand.
-
-
Have a lovely time.
-
Attachments
-
- BTN SHRINK.livecode.zip
- Stack.
- (1.23 KiB) Downloaded 140 times
-
andresdt
- Posts: 156
- Joined: Fri Aug 16, 2019 7:51 pm
-
Contact:
Post
by andresdt » Wed May 25, 2022 7:57 pm
Hi @Samuele
Here I share an idea of how to achieve the same visual effect of the button. But without encoding, just create the two versions of the image to display. Normal and pressed and use a button.
-
Attachments
-
- ShrinkCenter.livecode.zip
- (24.48 KiB) Downloaded 173 times
-
andresdt
- Posts: 156
- Joined: Fri Aug 16, 2019 7:51 pm
-
Contact:
Post
by andresdt » Wed May 25, 2022 7:58 pm
@Richmond62, very interesting your example, just a little suggestion. If in the repeat where he sends to wait, he tells him to wait with messages. Everything doesn't freeze until the animation ends. Thanks for sharing this!
Last edited by
andresdt on Fri May 27, 2022 4:13 pm, edited 1 time in total.
-
Samuele
- Posts: 282
- Joined: Mon Oct 11, 2021 7:05 pm
Post
by Samuele » Wed May 25, 2022 9:31 pm
Hi richmond62, It's been a long time! thanks but it wasn't exactly what I was trying to achieve, thanks anyways!
andresdt, thanks! that's actually pretty good but the problem is that I want to do that with all the buttons in my app and since I'll have to import two sizes for every image it will mean that the size of my app will double and it's quite a lot... or is there a way to decrease the size of the app?
Thanks!
Samuele.
-
andresdt
- Posts: 156
- Joined: Fri Aug 16, 2019 7:51 pm
-
Contact:
Post
by andresdt » Thu May 26, 2022 12:21 am
Remove the label from your images, it occurs to me that you can create two images for each button variant you use in your app. If all the buttons are the same style and size. You will only have to use two images.
Set the images for the icon and the hiliteIcon properties of your buttons.
Then set the iconGravity property to the bottom and make the button the width and height of the largest image.
This should create a visual effect similar to what you are looking for.
-
Samuele
- Posts: 282
- Joined: Mon Oct 11, 2021 7:05 pm
Post
by Samuele » Fri May 27, 2022 4:45 pm
Sorry I didn't quite understand

What do you mean with label of the image?
Just to be clear I have a lot of different images and what I was trying to say is that I would have to double every one of the images (that aren't the same) to create this effect, 1 mage a bit bigger than the other.
Samuele.
-
andresdt
- Posts: 156
- Joined: Fri Aug 16, 2019 7:51 pm
-
Contact:
Post
by andresdt » Fri May 27, 2022 5:07 pm
Samuele wrote: ↑Fri May 27, 2022 4:45 pm
Sorry I didn't quite understand

What do you mean with label of the image?
Just to be clear I have a lot of different images and what I was trying to say is that I would have to double every one of the images (that aren't the same) to create this effect, 1 mage a bit bigger than the other.
The label that has the images of the example you shared is "Start".
If the text is what changes from one image to another. You only have to use 2.
Look at the stack that I share
-
Attachments
-
- ShrinkCenter.livecode.zip
- (34.19 KiB) Downloaded 157 times