Get name of button

Hi,

I have a button with icon in my interface.
It is connected via bluebox to the property example myButton
It is connected also when I push it invoking an handler.
When the routine is invoked, how can I recognize it?
It has icon, not title, so I cannot use:

set objectName to (title of sender) as string

Rufus

Do you have the handler connected to more than this one button? If you don’t, then there is no need to get the identity of the button. If you need to know which button called the handler you can check to see if the sender is your button with: if sender is myButton then…

Ric

Hi,

yes, I have some button connected to one handler.
Your suggestion solved the problem…

BUT

If I want to log the sender as debugging the console say:

<NSButton: 0x20074a0c0>

How I can log the property name of button?

Rufus

I don’t think that there is any direct way to get the name of a property by logging. If you really need to see that name in your log, then I think you would have to do something like this:

on myButtonHandler_(sender)
		if sender is myButton then
			log "myButton"
		else if sender is mySecondButton then
			log "mySecondButton"
		end if
		--etc.
	end myButtonHandler_

Ric

Hi,

an alternative way is to assign tags to UI elements