How can one reset a tab panel?

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
RCozens
Posts: 138
Joined: Thu Aug 05, 2021 6:42 am
Location: Manchester, CA USA

How can one reset a tab panel?

Post by RCozens » Sun Aug 22, 2021 2:54 am

Serendipity Editors is a two-card stack, and I am using a tab panel to navigate between the Image Editor and the Icon Editor. Each tab contains the name of one of the cards, so

on menuPick theCardName
go to card theCardName
end menuPick

does just fine....until I close the stack from the second card. The next time the stack is opened the tab is set as it was on the card that was visible when the stack was closed. I've tried the same technique with a grouped tab panel on a simple three-card stack with cards named "Tab 1", "Tab 2", & "Tab 3" with the same result.

I realize the tab panel is designed for a dialog box, not for navigation; but I like the effect on a stack with a small number of cards. So I'm looking for a solution or a workaround. I tried putting a closeStackRequest handler in the script of the second card that clicks at the appropriate tab, but no go.

When I follow the process in the Message Watcher I see:
focusIn
mouseDown
cREVGetsUpdate
menuPick
cREVGetsUpdate
cREVTable
cREVGeneral
mouseUp
mouseLeave

I'm guessing the tab switch is handled in one of the cREV messages. Sending a menuPick message does not change the tab, and while I can see the tabs in the text of the panel. I can't identify a property that determines which tab is hilited.

Any thoughts/suggestions would be appreciated.
Rob Cozens dba Serendipity Software Company
Manchester, CA USA

Each new generation gives more attention to the man-made world...
and less attention to the world that made man.

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How can one reset a tab panel?

Post by Klaus » Sun Aug 22, 2021 1:26 pm

Hi Rob,

you can use the "menuhistory" property:

Code: Select all

...
## if you don't want to execute the TAB buttons script
lock messages

set the menuhistory of btn "your tab panel here..." to 1
...
Hope that helps!


Best

Klaus

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: How can one reset a tab panel?

Post by stam » Sun Aug 22, 2021 1:38 pm

Hi Rob,

if i understood correctly you want to basically synchronise the selected tab with the selected card?

In that case it's easiest to simply set the menuHistory property of the tab panel button. For example, put a script in the preOpenCard handler to set the selected tab panel:

Code: Select all

on preOpenCard
    set the menuHistory of button "tab menu" to <the number of the card>
end preOpenCard
That way when you open the stack the tab panel will always indicate the card you're on.

I attach a simple example, hope that helps
Stam

---- EDIT ----
As usual Klaus got there just before me... out-Klaussed again!
Attachments
tab test.livecode.zip
(1.39 KiB) Downloaded 113 times

RCozens
Posts: 138
Joined: Thu Aug 05, 2021 6:42 am
Location: Manchester, CA USA

Re: How can one reset a tab panel?

Post by RCozens » Sun Aug 22, 2021 8:06 pm

Problem solved: mea ignorant.

The first thing I did after downloading v9.6.2 was read the User Guide to see how LiveCode had evolved in the last 15 years. But I probably just skimmed menus because my app and Serendipity Editors use point-&-click interfaces. Once I set the mernuHistory when opening the stack the problem was eliminated.

Thanks for helping me.
Rob Cozens dba Serendipity Software Company
Manchester, CA USA

Each new generation gives more attention to the man-made world...
and less attention to the world that made man.

RCozens
Posts: 138
Joined: Thu Aug 05, 2021 6:42 am
Location: Manchester, CA USA

Re: How can one reset a tab panel?

Post by RCozens » Tue Oct 05, 2021 7:49 pm

An update to this thread for persons planning to distribute LiveCode stacks/apps across multiple platforms:

The visual representation of tab controls is so different between MacOS and Win32 that I would not recommend using tab controls except in the manner for which they were originally designed: in dialog boxes. They could hardly be more different on the two platforms. Here are the visuals:

The difference in titles was scripted by me; the rest of the differences (tab placement, background color, and coloration of the selected tab) are all via LiveCode.

I still like visuals and utility of navigating stacks with just a few cards in Windows, and I will add a kludge so I can duplicate Serendipity Editor's utility on MacOS; but I would not recommend using tab controls for any purpose beside the use they were designed for without careful consideration of the visual differences.

Cheers!
Attachments
Tab Control Background.png
Mac Screen.png
Mac Screen.png (65.59 KiB) Viewed 2062 times
Rob Cozens dba Serendipity Software Company
Manchester, CA USA

Each new generation gives more attention to the man-made world...
and less attention to the world that made man.

Post Reply

Return to “Talking LiveCode”