Deselect textfields with button

Discussion in 'Mac Programming' started by abcdefg12345, Apr 4, 2014.

  1. abcdefg12345, Apr 4, 2014
    Last edited: Apr 4, 2014

    abcdefg12345 macrumors regular

    abcdefg12345

    Joined:
    Jul 10, 2013
    #1
    I'm working on an app with multiple textfields and some of them have to be editable but i also need a way to deselect textfields so i can type some numbers using key equivalent functions

    is there a way i can have a button that when i click deselects the textfields so that key equivalent functions work

    thats what i did but still can't type with key equivalent

    Code:
    - (IBAction)editoff:(id)sender
    {
        [_Field1 setEditable: NO];
        [_Field1 setSelectable: NO];
        [_Field2 setEditable: NO];
        [_Field2 setSelectable: NO];
        [_Field3 setEditable: NO];
        [_Field3 setSelectable: NO];
    
    }
    
    - (IBAction)editon:(id)sender
    {
        [_Field1 setEditable: YES];
        [_Field1 setSelectable: YES];
        [_Field2 setEditable: YES];
        [_Field2 setSelectable: YES];
        [_Field3 setEditable: YES];
        [_Field3 setSelectable: YES];
    }
    the textfields are becoming non editable but is still can't use buttons
     
  2. abcdefg12345 thread starter macrumors regular

    abcdefg12345

    Joined:
    Jul 10, 2013
    #2
    Don't worry about it i found what i was looking for

    .h
    Code:
    @property (assign) IBOutlet NSWindow *MainWindow;
    - (IBAction)Deselectfields:(id)sender;
    .m
    Code:
    - (IBAction)Deselectfields:(id)sender
    {
        [_MainWindow endEditingFor: nil];
    }
     

Share This Page