Page 1 of 1

scripting a click on a tab panel

Posted: Tue Mar 20, 2018 7:57 pm
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

Re: scripting a click on a tab panel

Posted: Tue Mar 20, 2018 8:08 pm
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

Re: scripting a click on a tab panel

Posted: Tue Mar 20, 2018 8:25 pm
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 =)

Re: scripting a click on a tab panel

Posted: Tue Mar 20, 2018 10:46 pm
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