Dynamically adding UI elements (with event handling)

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
maarten.koopmans
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 20
Joined: Sun Dec 28, 2008 3:26 pm

Dynamically adding UI elements (with event handling)

Post by maarten.koopmans » Sat Apr 02, 2011 8:23 am

Hi,

I have a stack where I want the user to be able to add objects ((e.g. images, lines, text). I can set the tool to [ ... ]. Think an "editable page". But my problem then is (let's take an image for example):

- how do I make it so that the user can add an image to the placeholder
- move the image
- resize it

Same for lines, texts, ... any ui element, really - I am trying to create a mock-up tool.

My thoughts were be that I:

a) have the user add the object to the the stack
b) dynamically attach handlers to the newly created object that implement any desired object-specific behavior (i.e. move. (reset image source, crop, ...)

How do I add the handlers dynamically (I really haven't been able to find it), and moreover, where do I store these templates in the overall stack.

I think I haven't wrapped my head around the LiveCode model to do these more dynamic things, *any* help would be greatly appreciated!!!

Thanks, Maarten

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Dynamically adding UI elements (with event handling)

Post by Dixie » Sat Apr 02, 2011 11:20 am

Hi Maarten...

Have a look at the stack that I have attached... It shows you how to create the properties of an image, put a handler into the script of the image and then create it, I think that the script will be fairly self-explanatory. this example doesn't cover everything you asked about, but should get you started in the right direction...

Have a look at templateImage and create in the dictionary...

hope it helps,

Dixie
Attachments
Add Things.zip
(1.35 KiB) Downloaded 262 times

Post Reply