How to simulate a Mouse Click on a row in NSTableView

  • hi,
    I have a problem :how to simulate a Mouse Click on a row in NSTableView

    the specific condition is that
      there are two tables in a window, we can image it is a phonebook.
    in the window, the left table is the groupList, and the right is the userList.

    I use a example to show my question
              in the groupList I have several group such as
                          frends
                          family
                          teacher
    and so on.
            we click frends row,we can get it's members  in the userList .

    How to  simulate "click frends row" ,and the userList table to show freds's members?

    hope to someone to help me!

    best regards,

    Ruby

    _________________________________________________________________
    MSNÊ¥µ®ÀñÎï»ðÈȵdz¡£¬Ãâ·Ñ·¢·ÅÖУ¬¿ìÀ´ÁìÈ¡°É£¡
    http://im.live.cn/emoticons/?ID=18
  • On 11/01/2008, at 1:19 PM, DongRuchan wrote:

    >
    > hi,
    > I have a problem :how to simulate a Mouse Click on a row in
    > NSTableView
    >
    > the specific condition is that
    > there are two tables in a window, we can image it is a phonebook.
    > in the window, the left table is the groupList, and the right is
    > the userList.
    >
    > I use a example to show my question
    > in the groupList I have several group such as
    > frends
    > family
    > teacher
    > and so on.
    > we click frends row,we can get it's members  in the userList .
    >
    > How to  simulate "click frends row" ,and the userList table to show
    > freds's members?
    >
    > hope to someone to help me!
    >
    > best regards,
    >
    > Ruby

    Hi Ruby,

    I think you won't need to simulate a mouse click.  Just select the
    row you want in the userList:

    NSIndexSet *indexSet = [NSIndexSet
    indexSetWithIndex:indexOfYourTargetRow];
    [myUserListTableView selectRowIndexes:indexSet
    byExtendingSelection:NO];

    This will select the row.  This will work on OS X 10.3 or later.

    Ron
  • On 10 Jan 08, at 18:19, DongRuchan wrote:
    > hi,
    > I have a problem :how to simulate a Mouse Click on a row in
    > NSTableView

    I suspect you're asking the wrong question. It is rarely the case that
    you actually need to synthesize user-interface events. There are
    usually much cleaner (and more flexible) ways of getting the same
    effect which don't depend on details of the user interface.

    > the specific condition is that
    > there are two tables in a window, we can image it is a phonebook.
    > in the window, the left table is the groupList, and the right is the
    > userList.
    >
    > I use a example to show my question
    > in the groupList I have several group such as
    > frends
    > family
    > teacher
    > and so on.
    > we click frends row,we can get it's members  in the userList .
    >
    > How to  simulate "click frends row" ,and the userList table to show
    > freds's members?

    The question you probably intend to ask here is:

      "How can I cause an object in a master-detail interface to be
    selected?"

    If you're working with Cocoa Bindings and NSObjectController (or its
    subclass NSArrayController), the solution is pretty straightforward:
    the class supports a number of methods to manipulate the selection.

    If you're trying to roll your own implementation of something similar,
    all bets are off. You can manipulate the selections in a table view
    manually - the relevant method is pretty obvious - but getting other
    views to reflect this accurately is your responsibility (and is likely
    to be messy).
previous month january 2008 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