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

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

scripting a click on a tab panel

Post by rjd »

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: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: scripting a click on a tab panel

Post by Klaus »

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: 16
Joined: Thu Aug 29, 2013 11:29 am

Re: scripting a click on a tab panel

Post by rjd »

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: 10501
Joined: Wed May 06, 2009 2:28 pm

Re: scripting a click on a tab panel

Post by dunbarx »

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