comp.lang.ada
 help / color / mirror / Atom feed
* TASH question about binding command to button
@ 1999-10-20  0:00 Ada2001
  0 siblings, 0 replies; only message in thread
From: Ada2001 @ 1999-10-20  0:00 UTC (permalink / 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.




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-10-20  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-10-20  0:00 TASH question about binding command to button Ada2001

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox