Professional Web Applications Themes

NSOutlineView, NSWindowController, ctrl-click - Mac Programming

Hello NG In my application i have a NSWindowController that controls the the instances of a nib-based window. In these (multiple) windows i have a NSOutlineView, combined in a NSSplitView like you have in the mail application. The action of the NSOutlineView is set to that NSWindowController class via setAction and setTarget in the awakeFormNib function. With the target function i can execute some code when the user clicks on the NSOutlineView. Now I want to have a additional function to be executed when there is a mouse-click and the ctrl key is pressed. How can I catch this event ...

  1. #1

    Default NSOutlineView, NSWindowController, ctrl-click

    Hello NG

    In my application i have a NSWindowController that controls the the instances of a
    nib-based window.
    In these (multiple) windows i have a NSOutlineView, combined in a NSSplitView like
    you have in the mail application. The action of the NSOutlineView is set to that
    NSWindowController class via setAction and setTarget in the awakeFormNib function. With the target
    function i can execute some code when the user clicks on the NSOutlineView. Now I want to have a
    additional function to be executed when there is a mouse-click and the ctrl key is pressed. How
    can I catch this event combination ? I have tried to implement a -(void)mouseDown{}
    function for the window but that works only for the window and not for my OutlineView.

    Thank you for your time and help and please excuse my poor english.

    Florian

    Florian Guest

  2. #2

    Default Re: NSOutlineView, NSWindowController, ctrl-click

    Florian Zschocke wrote: 

    so what you do is derive your own inherited class from NSOutlineView,
    and override the [NSOutlineView mouseDown:] method. get the current
    event, and see what modifier keys are being held down.

    a word of caution, though: the cocoa mouse functions don't work as you'd
    expect. they don't work as *i* expected them to, anyway. there is a
    mouseMoved: and a mouseUp:, but you can't count on them at all. most
    long and involved mouse actions, like dragging something, start in
    mouseDown, then there will be some code that creates a new event loop in
    place, and they do the whole thing right there, and mouseMoved: and
    mouseUp: never get called at all. pretty lame, if you ask me. it's not
    very OO, writing new event loops to usurp the main one, and it defeats
    the purpose of having all those mouse functions.
    Jhnny Guest

  3. #3

    Default Re: NSOutlineView, NSWindowController, ctrl-click

    Jhnny Fvrt (it means "halo, then resonate") <com> wrote: 
    Thank you Jhnny - that works fine for me.
    It is easier than I thought. I just check the modifier keys and if ctrl is not pressed, I
    call the [super mouseDown:theEvent] inside my mouseDown function . So you can add any
    single behavior without writing a new event loop.
    Thanks a lot - Florian

    Florian Guest

  4. #4

    Default Re: NSOutlineView, NSWindowController, ctrl-click

    Florian Zschocke wrote: 

    yes, so long as the single behavior you want to add is not a drag of
    some sort! then you've got to write a temporary event loop. it's not
    too hard, though. it's explained very thoroughly in the cocoa docs, and
    they've got a sample drag event loop that i copied exactly to make
    something or the other work right, i can't remember what now.
    Jhnny Guest

Similar Threads

  1. cfselect multiple select without ctrl + click
    By mistah_cat in forum Coldfusion - Advanced Techniques
    Replies: 1
    Last Post: February 22nd, 01:47 AM
  2. [NSWindowController] dealloc is not called
    By Robert in forum Mac Programming
    Replies: 7
    Last Post: April 23rd, 05:37 AM
  3. NSWindowController - new instance ?
    By Florian in forum Mac Programming
    Replies: 3
    Last Post: April 20th, 06:11 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139