How to build a dynamic user-option pop-up menu

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: How to build a dynamic user-option pop-up menu

Post by bn » Wed Sep 07, 2016 3:42 pm

Hi Mark,

Code: Select all

on mouseDown
   put myChoices into btn "pop"
end mouseDown

on mouseUp
   popup btn "pop"
end mouseUp
I would put it into the mouseDown part as for a pop-up user interface is the usual thing.

Code: Select all

on mouseDown
   put "1" & cr & 2 & cr & "3" into myChoices
   put myChoices into btn "pop"
   popup btn "pop"
end mouseDown
Kind regards
Bernd

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am

Re: How to build a dynamic user-option pop-up menu

Post by marksmithhfx » Wed Sep 07, 2016 4:19 pm

Hi Bernd, have an sqlite file handy? Give this a try. It uses your two button pop-up solution and I like it (the "pop" button is hidden).

Cheers,

Mark
Attachments
Read SQL Schema.livecode.zip
Simple stack displays table names and field attributes in an SQLite file
(2.09 KiB) Downloaded 204 times
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: How to build a dynamic user-option pop-up menu

Post by bn » Wed Sep 07, 2016 4:41 pm

Hi Mark,

this looks very nice and useable. The only squabble I have that it pops up on mouseUp, a pop-up usually pops up on mouseDown.

Kind regards
Bernd

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

Re: How to build a dynamic user-option pop-up menu

Post by jacque » Wed Sep 07, 2016 5:50 pm

I think we should add it to the documentation... it's a clever hack
It's already in the docs, under "popup". :-)That's pretty much what the command is for. You can also pop up whole stacks if you construct them properly.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am

Re: How to build a dynamic user-option pop-up menu

Post by marksmithhfx » Thu Sep 08, 2016 2:57 am

Oh good point (sorry I missed your earlier post on this). I've switched it around to pop up on mouse down.

Jacque, now you tell me :)

M
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am

Re: How to build a dynamic user-option pop-up menu

Post by marksmithhfx » Sat Sep 10, 2016 2:07 am

PS I deleted this earlier when I found the tabbed menu mode in the documentation (Devan Asay documents how it exists in the online docs and not in the IDE) but after reviewing it I think I would still come to the same conclusion so I am putting my original post back up....

Under menuMode there is some discussion of "tabbed". In particular the menu mode property of a button being "tabbed". I have searched high and low in several button types and can't find this menuMode type although we do have a tool type called Tab Panel. I'll tell you what I was thinking... why not just put a row of tabs at the bottom of the table field and put the table names in the tabs. Select a tab and the contents of the table field change, just like an Excel spreadsheet. Possible?

So I decided to do a bit of experimenting. I placed a tab panel under a basic table, although it was impossible to entirely get rid of the grey "panel" area, so that was the first problem. Next, while it expands individual tabs to accommodate different lengths of text, it does not expand the length of the visible tab area to accommodate more tabs... in short, unlike a menu, it's not very dynamic.

I think to do what I want I would have to make my own tab control that is an image of tabs that can be resized to fit the area desired, grows and shrinks dynamically, has scroll controls to scroll the tabs when necessary, and has no-border buttons on it to hold the tab values. So, two questions related to this. 1. has it been done? 2. could it be done as a widget?

Thanks, and see my crude example below. You'll need to supply your own SQLite file for basic table content.

Thoughts, suggestions?

Mark
Attachments
Read SQL Schema.livecode 2.zip
Example demonstrates using a tab panel to control content of a basic table. Requires an Sqlite file.
(2.29 KiB) Downloaded 201 times
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: How to build a dynamic user-option pop-up menu

Post by bn » Mon Sep 12, 2016 10:51 pm

Hi Mark,

I have put a "segmented control" widget alongside your tabbed button. See the script of the widget and of button "Connect to DB".

this version of your stack runs only in 8.x.x. I used 8.1.0 rc2.

It works quite well, except when there is only one table. Then the right border of the widget is straight instead of rounded.

Have a look.

Kind regards
Bernd
Attachments
Read SQL Schema version8.livecode.zip
(3.2 KiB) Downloaded 198 times

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am

Re: How to build a dynamic user-option pop-up menu

Post by marksmithhfx » Wed Sep 14, 2016 12:32 am

Thanks Bernd. Interesting control. Do you know if there are any documents around describing how it was written? Source?

Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: How to build a dynamic user-option pop-up menu

Post by bn » Wed Sep 14, 2016 12:48 am

Hi Mark,
Interesting control. Do you know if there are any documents around describing how it was written? Source?
the segmented control is written in Livecode Builder, the documentation is in the dictionary of the 8.x.x series -> API choose from popup button "chooseApi..xxx" segemented control.

The source code is in the application bundle of LC 8.x.x.app. On a Mac right click on the application bundle (the program icon) and choose "show content"

then you find the sourc of the segemented control in
Contents -> Tools -> Extensions -> com.livecode.widget.segmented -> segmented.lcb

segmented.lcb is the source code of the widget. You can open that file in basically any text editor. Atom or BBEdit are recommended.

Don't blame me; you asked for the source code. :)

Kind regards
Bernd

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am

Re: How to build a dynamic user-option pop-up menu

Post by marksmithhfx » Mon Oct 03, 2016 4:58 am

bn wrote:then you find the sourc of the segemented control in
Contents -> Tools -> Extensions -> com.livecode.widget.segmented -> segmented.lcb

segmented.lcb is the source code of the widget. You can open that file in basically any text editor. Atom or BBEdit are recommended.

Don't blame me; you asked for the source code. :)
Thanks Bernd, that was quite helpful. I imagine pairing the source with the Livecode Builder Language Reference manual might help illuminate one's grasp of the thing. Also looking forward to some of the infinite livecode projects - which were to be fully worked examples demonstrating this widget/builder technology. Can hardly wait!

:)
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

Post Reply