From: Ada2001 <ada2001@my-deja.com>
Subject: TASH question about binding command to button
Date: 1999/10/20
Date: 1999-10-20T00:00:00+00:00 [thread overview]
Message-ID: <7ukl1k$8oa$1@nnrp1.deja.com> (raw)
Hello,
I am attempting to use TASH for the first time. My objective is to
create a Tk interface for a game written in Ada.
I have created a 10x5 array of Ada objects of type Cell as defined here.
type Cell_Type is
record
Name : String(1..4);
Color : Peg_Type;
Button : Tcl.Tk.Ada.Button;
end record;
I want to bind the cell buttons to a command that will cycle the button
color through the available values using something like the following
demo-derived code (which doesn't yet work):
function Cycle_Color_Command (
Clientdata : in Integer;
Interp : in Tcl.Tcl_Interp;
Argc : in C.Int;
Argv : in Cargv.Chars_Ptr_Ptr )
return C.Int is
begin -- Cycle_Color_Command
Tcl.Tk.Ada.Set_Trace (True);
Cell(I,J).Color := Next_Color(Cell(I,J).Color));
Tcl.Tk.Ada.Configure (Cell(I,J).Button, "-background " &
Peg_Type'Image(Cell(I,J).Color) & " -command Cycle_Color");
return Tcl.Tcl_Ok;
end Cycle_Color_Command;
My question is: If I bind all 50 Cell(I,J). Button objects to the single
Cycle_Color_Command function, is there a way to pass in the identity
(i.e. I and J) of the particular Cell(I,J).Button where the mouse click
occurred? I don't want to create 50 distinct commands, one per button,
if I can avoid it. I suspect the identity is encoded in the Argv
function argument but I don't know how to decipher it.
Thanks,
F. Britt Snodgrass (britt@acm.org)
Sent via Deja.com http://www.deja.com/
Before you buy.
reply other threads:[~1999-10-20 0:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox