Date: Tue, 6 May 2003 15:10:56 +0100 To: lablgtk at kaba.or.jp Subject: Toggle button callback question Message-ID: <20030506141056.GB9761 at redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline From: Richard Jones I think this is a very simple question - but it seems to be defeating me nevertheless. I have code which looks like this: let menu_bold () = (* I want this function to do two different things depending on whether the toggle button is now active or inactive. *) let main () = (* ..... *) (* This is where I create my toolbar containing a toggle button. *) let toolbar = GButton.toolbar ~packing:vbox#pack () in toolbar#insert_toggle_button ~text:"Bold" ~callback: menu_bold (); The problem is that (a) The menu_bold cannot 'see' the button object, so it can't call button#active to find the state. (b) I'd do this in C using a global variable to store the button object or a forward prototype of some sort. Neither of these things seem to exist in OCaml. So I'm confused about how to structure the program to allow this - possibly reflecting my background as a C/Perl programmer! Rich. -- Richard Jones, Red Hat Inc. (London) and Merjis Ltd. http://www.merjis.com/ http://www.annexia.org/ Freshmeat projects: http://freshmeat.net/users/rwmj PTHRLIB is a library for writing small, efficient and fast servers in C. HTTP, CGI, DBI, lightweight threads: http://www.annexia.org/freeware/pthrlib/