[ltk-user] Button/Sender associated with Event?

Eric Hochmeister erichochmeister at gmail.com
Sun Feb 5 07:56:01 UTC 2006


Hi,

The functionality I'm looking for is that I want to set a button's
action to be a function.  When the function is called, I want to know
which button called it.  This is because many buttons can be linked to
the same function.  How do I accomplish this?

I looked at the docs for :command and it seems like they only pass
"values" to the function.  (what was changed, etc.)

So I figured, maybe I need to look at binding, it seems to send out an
event.  So I tried it, and I noticed this...

radio button value = NILl:(:EVENT "w13" 13 16 ?? ?? ?? ?? 273 324 1)<=
event = #S(LTK:EVENT :X 13 :Y 16 :KEYCODE ?? :CHAR ?? :WIDTH ??
:HEIGHT ?? :ROOT-X 273 :ROOT-Y 324 :MOUSE-BUTTON 1)

The Tcl representation seems to have access to the widget that caused
the event ie. "w13" but the lisp representation doesn't.  I looked at
the structure for event and this indeed seems to be the case.

(defstruct event
  x
  y
  keycode
  char
  width
  height
  root-x
  root-y
  mouse-button
  )

So now I'm puzzled.

Is there any way to accomplish the functionality I'm looking for?? 
(other than hacking up my own way with functions which emulate this?) 
I must be missing something.

-----------------

Also, another side question.  I'm playing around with radio buttons
and I was trying to figure out how to get the state to be on or off..
and by state I mean whether the radio button is selected or not (ON or
OFF).  From what I can tell, if the :value of a radio button is nil,
then it's ON.  If it has any other value than nil then its OFF.  Is
this right??  Its just puzzling me cause it seems so unintuitive.

Ok, thats all for now.

Thanks!

Eric



More information about the ltk-user mailing list