Saturday, March 28, 2020

#1 2020-02-21 05:39:23 pm

Marius_Magnificus
Member
Registered: 2019-05-05
Posts: 16

NSComboBox: How to deselect an item

Hi everybody,

I have a NSComboBox and any time a selection is made within it, the selection populates the NSComboBox's principal placeholder as expected.

What I'd like to accomplish is that anytime a selection is made, the principal placeholder gets empty immediately.

These are the approaches I tried so far but all of them end thowing an error message:

-- 1 --
property myComboBox : missing value

on myComboBoxClick_(sender)
  myComboBox's deselectItem(myComboBox's indexOfSelectedItem)   
end myComboBoxClick_

# Yields the following error message:
# -[NSComboBox deselectItem]: unrecognized selector sent to instance 0x10071af10 (error -10000)

-- 2 --
tell myComboBox
  deselectItem(myComboBox's indexOfSelectedItem)
end tell

# Yields the same error message as above:
#-[NSComboBox deselectItem]: unrecognized selector sent to instance 0x10071bc20 (error -10000)


I'm sorry for this pretty basic question but I couldn't find out how to use this function correctly:

func deselectItem(at index: Int)

Thank you in advance.

Marius

Offline

 

#2 2020-02-22 10:04:53 pm

Marius_Magnificus
Member
Registered: 2019-05-05
Posts: 16

Re: NSComboBox: How to deselect an item

I've made a small progress but still not good enough:

I've replaced 'deselectItem' by 'deselectItemAtIndex' and surround the statement into '[]', like this:

[prComboBox's deselectItemAtIndex:(prComboBox's indexOfSelectedItem)]

The good thing is that the placeholder gets clear
The bad thing is that at the end a new error message is genarated:

No result was returned from some part of this expression. (error -2763)

I know this is a very simple question, but for me is difficult to see what is the problem because I'm starting with AppleScript and I do not have any knowledge of Objective C.

Thank you in advance smile

Offline

 

#3 2020-02-22 11:07:11 pm

maro
Member
From:: Nerima, Tokyo, Japan
Registered: 2004-05-30
Posts: 84
Website

Re: NSComboBox: How to deselect an item

This works.

Applescript:


indexOfSelectedItem()

Applescript:


           set aInd to aCombo's indexOfSelectedItem()
           aCombo's deselectItemAtIndex:(aInd)

Model: MacBook Pro 2012
AppleScript: 2.7
Browser: Safari 13.0.1
Operating System: macOS 10.14


I wrote thousands of AppleScript to realize my idea. Natural language interface, voice recognition commander and so on. Though my mother toungue is strange language, Japanese, my most frequently write language is AppleScript. I believe it is for making things easy and powerful.

Offline

 

#4 2020-02-23 06:51:58 am

Marius_Magnificus
Member
Registered: 2019-05-05
Posts: 16

Re: NSComboBox: How to deselect an item

What a dummy mistake! yikes

I forgot to add the '()' in the function call...

Thank you for your help, Maro-san

Mariano R.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)