Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Remove of selection in table view



While that works, it's generally a good idea to avoid using the Obj-C methods when there already exists a technique in AppleScript.  Whilst I don't know the internal mechanics of AS Studio (eg, exactly how commands are hooked), I would think that using call method anything would make AppleScript have to do double work to execute the command (not necessarily double CPU time, granted).

That and the call method syntax just gets messy.  Compare:

set currentTableview to table view "myTable" of scroll view "myTable" of window "myWindow"
call method "deselectAll:" of currentTableview with parameter {true}

to

set selected rows of table view "myTable" of scroll view "myTable" of window "myWindow" to {}

or 

set selected row of table view "myTable" of scroll view "myTable" of window "myWindow" to 0

To continue with the other original question, why using the arrow keys does not trigger a clicked event, well, that statement in and of itself should answer it: keys don't "click", mouses do.  If the goal is trigger an event when the mouse clicks on the table view (thus changing the selection) then it would be best to use the "on selection changed" event (or any one of its variants).  This will catch both click and key down events that trigger the selection of the table view to change.  However, what it won't catch is if the user clicked on the currently selected row.  This can be worked around by using the following example set-up that (should) avoid a double run of your table code (this is totally untested but should give you a general idea of approaching it).

property lastSelectedRow : 0

on selection changed theObject
    if theObject's name is "myTable" then
        tableViewSubroutine()
        set lastSelectedRow to theObject's selected row
    end if
end selection changed

on clicked theObject
    if theObject's name is "myTable" then
        if theObject's current selected row equals lastSelectedRow then
            tableViewSubroutine()
        end if
    end if
end clicked

on tableViewSubroutine()
    (* do stuff *)
end tableViewSubroutine


Matthew Stuckwisch
Senior, Spanish and New Media
University of Alabama


On Apr 24, 2005, at 7:43 AM, Novice Software wrote:



set currentTableview to table view "myTable" of scroll view "myTable" of window "myWindow"
            call method "deselectAll:" of currentTableview with parameter {true}


John



I delete a row in a table by first selecting it and then clicking a delete-button, and then I disable the delete-button.
The problem is now that the table view automatically highlights the next row in the table.
How can I remove this selection?
The following code is by best guess (!), but it doesn't work:

        delete SelectedServerRow
        set enabled of button "DeleteRow" of window "Prefs" to false
        set rowIdx to selected row of table view "ServerTable" of scroll view "ServerTable" of window "Prefs"
        log {"313 rowIdx", rowIdx}
        set selected row of table view "ServerTable" of scroll view "ServerTable" of window "Prefs" to 0
        update table view "ServerTable" of scroll view "ServerTable" of window "Prefs"

Another thing is that using the arrow keys up/down changes the selection of the rows, however, no clicked-event are produced!
Any hints?

/Heinrich
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden

References: 
 >Remove of selection in table view (From: Heinrich Bjerregaard <email@hidden>)
 >Re: Remove of selection in table view (From: Novice Software <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.