[rkward-devel] Show element depending on spinbox value

Birk Diedenhofen mail at birkdiedenhofen.de
Tue Jul 30 14:45:21 UTC 2013


Hi!

I ran into the following issue with my rkward plugin. I'm trying to show 
and hide GUI elements depending on the value of a spinbox. If the 
spinbox value is zero, the text element stating "spinbox value is zero" 
should be shown on the following wizard page (see code example below). 
If the spinbox value is not zero, the text element stating "spinbox 
value is not zero" should be shown. However, irrespective of the spinbox 
value, I always get "spinbox value is not zero".

If I change the rk.XML.convert() expressions and replace 
"real=spinbox.value" by "int=spinbox.value", I have a somewhat different 
result. For spinbox values from 0 to 0.99, I get "spinbox value is 
zero". For spinbox values ranging from 1 to 2, I get "spinbox value is 
not zero".

I'm using rkward version 0.6.0 on Debian wheezy.


Regards,
Birk


require(rkwarddev)

local({
   spinbox.value <- rk.XML.spinbox("Choose number from 0.00 to 2.00:", 
min=0, max=2, initial=0)

   spinbox.value.is.zero <- rk.XML.text("spinbox value is zero", 
id.name="spinbox_value_is_zero")
   spinbox.value.is.not.zero <- rk.XML.text("spinbox value is not zero", 
id.name="spinbox_value_is_not_zero")

   wizard <- rk.XML.wizard(
     rk.XML.page(
       spinbox.value
     ),
     rk.XML.page(
       spinbox.value.is.zero,
       spinbox.value.is.not.zero
     )
   )

   logic <- rk.XML.logic(
     value.is.zero.convert <- 
rk.XML.convert(sources=list(real=spinbox.value), mode=c(equals=0), 
id.name="value_is_zero_convert"),
     value.is.not.zero.convert <- 
rk.XML.convert(sources=list(real=spinbox.value), mode=c(notequals=0), 
id.name="value_is_not_zero_convert"),

     rk.XML.connect(governor=value.is.zero.convert, 
client=spinbox.value.is.zero, set="visible"),
     rk.XML.connect(governor=value.is.not.zero.convert, 
client=spinbox.value.is.not.zero, set="visible")
   )

   plugin.dir <<- rk.plugin.skeleton(
     "test",
     provides=c("logic", "wizard"),
     xml=list(logic=logic, wizard=wizard),
     pluginmap=list(name="test spinbox", hierarchy=list("analysis", 
"test spinbox")),
     dependencies=rk.XML.dependencies(),
     load=TRUE,
     overwrite=TRUE
   )
})




More information about the Rkward-devel mailing list