Sunday, November 19, 2017

#1 2017-11-04 05:20:43 am

ProGrammer
Member
Registered: 2016-12-16
Posts: 16

Hidding a Custom Box based on Tab View Selection

My AppleScript Application in Xcode contains Tab View component with multiple tabs.

Two buttons are linked to the selectNextTabViewItem and selectPreviousTabViewItem respectively to control the switching from one tab to the next (and back).

Here is where I am stuck:
I do not want the PREVIOUS button to show if the first tab is selected (obviously it makes no sense to have a back button on the initial tab). The buttons sit within a 'Custom Box' (Xcode component), which has a Drawing: Hidden checkbox (as per the Attributes Inspector) that is currently unchecked, so ideally I am looking for a way to toggle this hidden property depending on the selection of the tab, as the button will also become invisible.

Note: The buttons sit below the tab view component, not inside it, hence their visibility is independent of the tab selection. I figured it would be smarter to do it this way instead of two buttons in every tab to control the same thing.

From my research, I have found another article from 10 years ago, describing something similar using the didSelectTabViewItem function. However, its documentation is very vague in my opinion.
I would really appreciate your help in guiding me to the appropriate solution


Filed under: applescript, xcode, NSTabView

Offline

 

#2 2017-11-04 06:20:26 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5175

Re: Hidding a Custom Box based on Tab View Selection

Make sure your script is the tab view's delegate (make the connection), and then add a handler something like this:

Applescript:

on tabView:tabView didSelectTabViewItem:tabViewItem
   if (tabViewItem's isEqualTo:(tabView's tabViewItemAtIndex:0)) as boolean then
       -- the first tab has been selected...
   end if
end tabView:didSelectTabViewItem:


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Online

 

#3 2017-11-05 01:55:50 am

ProGrammer
Member
Registered: 2016-12-16
Posts: 16

Re: Hidding a Custom Box based on Tab View Selection

Shane Stanley, it worked like a charm! Thank you for the hint, that's a very elegant way of accomplishing it.

Make sure your script is the tab view's delegate (make the connection), and then add a handler something like this:

Applescript:

on tabView:tabView didSelectTabViewItem:tabViewItem
if (tabViewItem's isEqualTo:(tabView's tabViewItemAtIndex:0)) as boolean then
-- the first tab has been selected...
end if
end tabView:didSelectTabViewItem:

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)