scripting a click on a tab panel

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

Post Reply
rjd
Posts: 10
Joined: Thu Aug 29, 2013 11:29 am

scripting a click on a tab panel

Post by rjd » Tue Mar 20, 2018 7:57 pm

Hi - is there a way to script a tab selection on a tab panel control? I've tried mouseUp and menuItem "tab 1" but those didn't work. I want to select a specific tab to open depending on a user's keyboard shortcut. Couldn't find anything else in the docs or forum yet to try. Thanks!

on rawKeyDown theKeyNumber
switch (theKeyNumber)

case 50 -- 2
if the ctrlKey is down then
send mouseUp ("Tab 2") to btn "tabpanel"

end if
break

case 51 -- 3
if the ctrlKey is down then
send mouseUp ("Tab 3") to btn "tabpanel"
end if
break
end switch
pass rawKeyDown
end rawKeyDown

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

Re: scripting a click on a tab panel

Post by Klaus » Tue Mar 20, 2018 8:08 pm

Hi rjd,

you can "set the menuhistory of btn xxx to y", where y is the number of the TAB you want to hilite/select.
Example: Tabbed button "el tabbo" with 3 tabs: tab1, tab2, tab3

Code: Select all

on mouseup
  set the menuhistory of btn "el tabbo" to 2
end mouseup
Will hilite/select the second tab "tab2" as if clicked, you get the picture. :-)

Best

Klaus

rjd
Posts: 10
Joined: Thu Aug 29, 2013 11:29 am

Re: scripting a click on a tab panel

Post by rjd » Tue Mar 20, 2018 8:25 pm

Thanks for the quick response, Klaus! I don't know how I didn't come across that in my searches but I'm so glad you knew it =)

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

Re: scripting a click on a tab panel

Post by dunbarx » Tue Mar 20, 2018 10:46 pm

Hi.

What Klaus knew.

You should know that all similar buttons will respond in this way. So if you have an option menu and want to "preset" its displayed selection, you can do the same thing.

Craig Newman

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”