Page 1 of 1

radio-button/check box bug

Posted: Sun Jun 17, 2007 7:15 am
by HPW
Without text the selected flag would not work.

Instead of:

Code: Select all

(define (radio-button id action text selected)
	(if text
		(net-send out (string "radio-button " id " " action " " (base64-enc text) " " selected "\n"))
		(net-send out (string "radio-button " id " " action "\n")))
)

(define (check-box id action text selected)
	(if text
		(net-send out (string "check-box " id " " action " " (base64-enc text) " " selected "\n"))
		(net-send out (string "check-box " id " " action "\n")))
)
it should read:

Code: Select all

(define (radio-button id action text selected)
	(if text
		(net-send out (string "radio-button " id " " action " " (base64-enc text) " " selected "\n"))
		(net-send out (string "radio-button " id " " action " nil " selected "\n")))
)

(define (check-box id action text selected)
	(if text
		(net-send out (string "check-box " id " " action " " (base64-enc text) " " selected "\n"))
		(net-send out (string "check-box " id " " action " nil " selected "\n")))
)

Posted: Sun Jun 17, 2007 4:36 pm
by Lutz
Without text the selected flag would not work.
This is how the syntax pattern specifies it. All functions with more than one optional parameter work this way. It makes for easier understanding of source code when you don't know the internal workings of the API functions.

Lutz

Posted: Sun Jun 17, 2007 4:40 pm
by HPW
I do not get it.
Without a text I can not preset the status?

Posted: Sun Jun 17, 2007 4:55 pm
by Lutz
You could either do:

Code: Select all

(gs:radio-button 'mybutton 'handler " " true) 

; or do

(gs:radio-button 'mybutton 'handler)
(gs:set-selected 'mybutton true)
In most cases users will specify some text for the radio button. So the second case will hardly ever occur.

Lutz