newLISP Fan Club

Forum => newLISP Graphics & Sound => Topic started by: HPW on June 17, 2007, 12:15:42 AM

Title: radio-button/check box bug
Post by: HPW on June 17, 2007, 12:15:42 AM
Without text the selected flag would not work.



Instead of:

(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:

(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")))
)
Title:
Post by: Lutz on June 17, 2007, 09:36:55 AM
QuoteWithout 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
Title:
Post by: HPW on June 17, 2007, 09:40:22 AM
I do not get it.

Without a text I can not preset the status?
Title:
Post by: Lutz on June 17, 2007, 09:55:22 AM
You could either do:


(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