Path: utzoo!attcan!uunet!mcvax!ukc!s1!jrwg From: jrwg@s1.sys.uea.ac.uk (John Glauert CMP) Newsgroups: comp.sys.mac.hypercard Subject: Re: How can I get instance variables in buttons Summary: Radio buttons: solution and problem Message-ID: <185@s1.sys.uea.ac.uk> Date: 14 Nov 88 11:23:43 GMT References: <77053@sun.uucp> <4089@Portia.Stanford.EDU> Distribution: comp Organization: UEA, Norwich, UK Lines: 59 In article <4089@Portia.Stanford.EDU>, duggie@Jessica.stanford.edu (Doug Felt) writes: > In article <77053@sun.uucp> DATJN@NEUVM1.Bitnet (Jakob Nielsen Tech Univ of Denmark) writes: > >I would like to be able to associate values with buttons > >... > >Do anybody have ideas for a cleaner way to program this?? > > Alas, one of the consequences of Hypertalk not being a full > object-oriented language is the inability to create your own objects > with state. Anyone who has tried to hack radio button groups will > understand this-- better still if they have tried to provide a 'tool' > for a naive user to create radio button groups. > ... I am no expert Hypertext programmer so this may be naive, but the scripts below do provide radio button groups: I use a hidden field to hold the state of the group given by the id of the selected button; blank implies no selection. Since button state is global, you need to adjust it to the right value when the card is opened. Script fragments below. A simplified version provides check boxes. Now the problem: I want to print this stack, but my radio buttons are not displayed properly because (it seems) opencard is not sent to cards before they are printed (hence I get the current button state everywhere). What can I do? John. In the script of the stack: on opencard set hilite of bkgnd button "M" to false set hilite of bkgnd button "F" to false if field "Gender" <> "" then set hilite of bkgnd button id (field "Gender") to true end if end opencard on radioclick group if field group = id of the target then set hilite of the target to false put "" into field group else if field group <> "" then set hilite of bkgnd button id (field group) to false end if set hilite of the target to true put id of the target into field group end if end radioclick The script of buttons "M" and "F": on mouseUp radioclick "Gender" end mouseUp