Creating Widgets

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: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
granata
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9
Joined: Fri Oct 15, 2010 12:27 am

Creating Widgets

Post by granata » Sat Apr 06, 2013 3:11 pm

Hello. I'm taking a stab creating a digital signage app in Live Code and could use some general guidance. My first question concerns the best way about building this. I envision an app that allows the user to choose, place on the screen and configure widgets such as clock, weather, tickets, etc.

In my head, I conceive this app as containing a main stack which would act as the canvas for placing these widgets and then substacks for each widget with a card for configuration and a card for display.

Is my thinking right on this? Or is there a better way?
On Twitter: @granata

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

Re: Creating Widgets

Post by dunbarx » Sat Apr 06, 2013 4:11 pm

Hi.

You could. And do try it that way.

I always try to keep the number of stacks to a minimum. I would use a single mainstack, and image objects for your widgets. These can all have scripts, and call configuration panes or windows which can be placed on a single substack which might have different cards on it as they pertain to the widget in question. The widgets themselves can be hidden or shown as requested, perhaps pulled from a treasure chest.

Or some other way.

Craig Newman

granata
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9
Joined: Fri Oct 15, 2010 12:27 am

Re: Creating Widgets

Post by granata » Sun Apr 07, 2013 3:49 pm

Craig, thanks for the help! I'll build a stack for each widget (there won't be many).

I've started by building a simple clock stack that consists of two cards, one that displays the time in a field and the other that allows the user to select the format for the time displayed. I also have a button on my main stack that toggles the locking of the widgets. A custom property (cLockWidgets) is toggled between true or false and, if set to true, the "clock widget" is locked into place. If set to false then the clock widget is able to be grabbed and moved around.

My challenge at this point is that I want to hide or show a configure button on the clock stack (and future stacks) depending on the value of cLockWidgets. Can you tell me the best way to go about this? I can accomplish it be specifically hiding or showing the button in an existing handler of the toggle button, but I feel like there must be a more efficient and scalable way.
On Twitter: @granata

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

Re: Creating Widgets

Post by dunbarx » Sun Apr 07, 2013 10:15 pm

I still think you are creating more cards or stacks than you need. Structurally, there is nothing wrong with this, but, for example, why have two cards for the time field and the format selection button? Why cannot they reside on the same card? You may have your reasons, but I just want to mention that new users frequently make lots of these objects, cards and stacks, when one might do.

Similarly, to me, hiding and showing objects is clean and simple to manage. Much better than creating separate cards to hold them. If you think about it, what is the difference between showing and hiding a card, (navigating) and showing and hiding an object on a single card?

But go ahead. Make the thing work, then think about streamlining.

Craig Newman

granata
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9
Joined: Fri Oct 15, 2010 12:27 am

Re: Creating Widgets

Post by granata » Sun Apr 07, 2013 10:32 pm

Craig,

You encouraged me to continue this way in your first response and, because the whole card/stack metaphor is one I easily wrap my mind around, I have no other reason than it is the path of least resistance. Maybe that is why other new users do the same.

In your previous post you mentioned using image objects for each widget. How would an image object contain something dynamic like a clock, slide show, ticker, etc?
On Twitter: @granata

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

Re: Creating Widgets

Post by dunbarx » Mon Apr 08, 2013 12:09 am

Why, it wouldn't.

Go for it.

Craig Newman

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”