Send command by double clicking on label osx?

Discussion in 'Mac Programming' started by canavid, Mar 18, 2014.

  1. canavid, Mar 18, 2014
    Last edited by a moderator: Mar 19, 2014

    canavid macrumors newbie

    Mar 18, 2014
    Im just new for programing for OSX I wonder to know how I can double click or click on a label then I can send a command? here is my h file

    - (IBAction)lbl1:(id)sender;
    and my m file is here

    - (IBAction)lbl1:(id)sender {
        [[NSPasteboard generalPasteboard] clearContents];
        [[NSPasteboard generalPasteboard] setString:_lbl1.stringValue forType:NSStringPboardType];
    when i double click or click on the label nothing happens and it will not copy the string of the label to pastboard thanks
  2. DennisBlah macrumors 6502


    Dec 5, 2013
    The Netherlands
    add an function like this:
    - (void)mouseDown:(NSEvent *)event {
        doubleClicked = No;
        if (event.clickCount == 2)
            doubleClicked = YES;
    check in your IBAction if the BOOL doubleClicked is true. then do your clipboard stuff.

    Are you sure you want to keep the clickable object an label instead of an button? You can just take off the border and stuff to make it look like a label?

Share This Page