At 11:34 PM -0500 4/5/03, Sherm Pendley wrote:You'll need to create a subclass of NSTabView. Override NSResponder's "mouseDown" method, get the modifier flags from the NSEvent object passed to that method, and respond appropriately.
Is this something that the current version of CB supports? Can you point me to any example code?
Ummm... never mind. I may have found an easier way. Typed into email, untested, use at your own risk, here be dragons, etc.
You can implement the following method in your tab view's delegate:
$OBJC_EXPORT{'tabView:shouldSelectTabViewItem:'} = {
'args'=>'@@', 'return' => 'c' };
sub tabView_shouldSelectTabViewItem {
}The above is called *before* switching tabs, and can be used to veto the switch by returning a false value (i.e. 0). It's commonly used to validate input before allowing the user to switch away from a tab. But, it may work for your purpose as well.
What you could do in this method is get the tab view's window, and then get the current event from the window, and the modifier flags from that event - something like this:
sub tabView_shouldSelectTabViewItem {
my ($self, $tabView, $tabViewItem) = @_;
my $flags = $tabView->window()->currentEvent()->modifierFlags();
if ($flags && (1 << 20)) {
# Command key is pressed
my $appDelegate = NSApplication->sharedApplication()->delegate();# $appDelegate should now be the object that was created in main.pl, and
# referred to there as $app. You can call one of this object's methods to
# create a new window controller object that controls a window that displays
# the same model that's displayed by this controller's window.
# You can also get the identifier from the requested tab view item above, and
# pass that as a parameter to $appDelegate's "create new window with tab
# selected" method.
# We've handled this ourselves, so veto the switch
return 0;
} # No modifiers, so allow the switch
return 1;
}Other modifier flags you may be interested in:
Caps lock: 1 << 16. Shift: 1 << 17. Control: 1 << 18. Alt/Option: 1 << 19.
There are others, but those are the most useful. You can find the complete list in NSEvent.h.
sherm--
