Changing an action programmatically....

  • Is it possible to change an action programmatically?

    I would like achieve something like this?:

        ifTheUserPressedThisTabItem setTheButtonToDoThisFunction

        // do something...

        ifTheUserPressedAnotherTabItem setTheSameButtonToDoAnotherFunction

        // do something else...

    I have the code in place for the correct tab selection, but I am not
    currently familiar with any code, that would allow me to choose more than
    one button action.  Is this possible or, am I regulated to a single
    connection in IB?

    Your suggestions are more than welcome.

    jim k
  • On Thursday, January 23, 2003, at 10:48 AM, jim kitchen wrote:

    > Is it possible to change an action programmatically?

    [...]

    > Your suggestions are more than welcome.

    I use things like...

        [mainButton setTitle:@"Reset"];
        [mainButton setAction:@selector(resetGame:)];
  • If I understand you correctly, you have a button that you want to send
    different actions depending on the selection in a tab view in the same
    window?

    How about something like this:

    - (void) tabView:(NSTabView *) tabView
    didSelectTabViewItem:(NSTabViewItem *) tabViewItem
    {
    if (tabViewItem == someItem)
    {
      [myButton setAction: @selector(buttonActionOne:)];
    }
    else
    {
      [myButton setAction: @selector(buttonActionTwo:)];
    }
    }

    j o a r

    On Thursday, Jan 23, 2003, at 16:48 Europe/Stockholm, jim kitchen wrote:

    > Is it possible to change an action programmatically?
    >
    > I would like achieve something like this?:
    >
    > ifTheUserPressedThisTabItem setTheButtonToDoThisFunction
    >
    > // do something...
    >
    > ifTheUserPressedAnotherTabItem setTheSameButtonToDoAnotherFunction
    >
    > // do something else...
    >
    > I have the code in place for the correct tab selection, but I am not
    > currently familiar with any code, that would allow me to choose more
    > than
    > one button action.  Is this possible or, am I regulated to a single
    > connection in IB?
    >
    > Your suggestions are more than welcome.
  • Leave the connection in IB, and have it set to match the state of the
    tab view when loaded from the nib file.

    j o a r

    On Thursday, Jan 23, 2003, at 18:59 Europe/Stockholm, jim kitchen wrote:

    > Should I disconnect the current connection in IB and, let the program
    > take
    > control, or does that matter?
  • joar,

    Thank you for your speedy reply...

    I will implement this code and see what happens...

    Should I disconnect the current connection in IB and, let the program take
    control, or does that matter?

    jim k

    On 1/23/03 9:43 AM, "j o a r" <joar...> wrote:

    > If I understand you correctly, you have a button that you want to send
    > different actions depending on the selection in a tab view in the same
    > window?
    >
    > How about something like this:
    >
    > - (void) tabView:(NSTabView *) tabView
    > didSelectTabViewItem:(NSTabViewItem *) tabViewItem
    > {
    > if (tabViewItem == someItem)
    > {
    > [myButton setAction: @selector(buttonActionOne:)];
    > }
    > else
    > {
    > [myButton setAction: @selector(buttonActionTwo:)];
    > }
    > }
    >
    > j o a r
    >
    > On Thursday, Jan 23, 2003, at 16:48 Europe/Stockholm, jim kitchen wrote:
    >
    >> Is it possible to change an action programmatically?
    >>
    >> I would like achieve something like this?:
    >>
    >> ifTheUserPressedThisTabItem setTheButtonToDoThisFunction
    >>
    >> // do something...
    >>
    >> ifTheUserPressedAnotherTabItem setTheSameButtonToDoAnotherFunction
    >>
    >> // do something else...
    >>
    >> I have the code in place for the correct tab selection, but I am not
    >> currently familiar with any code, that would allow me to choose more
    >> than
    >> one button action.  Is this possible or, am I regulated to a single
    >> connection in IB?
    >>
    >> Your suggestions are more than welcome.
    >
previous month january 2003 next month
MTWTFSS
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Go to today