rk.XML.switch: Create XML node "switch" for RKWard plugins

View source: R/rk.XML.switch.R

rk.XML.switchR Documentation

Create XML node "switch" for RKWard plugins

Description

This node can only be used in <logic> sections. If the provided property is logical, in the cases list you must also provide lists called true and false. If not, you must provide at least one list called case.

Usage

rk.XML.switch(condition, cases, modifier = NULL, id.name = "auto")

Arguments

condition

Either a character string (the id of the property whose state should be queried), or an object of class XiMpLe.node (whose id will be extracted and used).

cases

A named list of named lists. The lists contained must either be called true and false, setting the return values if condition is logical, or case and optionally default. You can provide as many case lists as you need, setting a return value for each condition == case respectively. Each list must contain either a fixed_value or a dynamic_value element. In addition, each case list must also have one standard element.

modifier

Character string, an optional modifier to be appended to condition.

id.name

Character string, a unique ID for this property. If "auto", IDs will be generated automatically from the condition ID.

Details

The values to be returned can be either fixed_value or dynamic_value. A fixed_value must be a character string which will be returned if the condition is met. Whereas a dynamic_value is the id of another property, an can be provided as either a character string or an object of class XiMpLe.node.

Value

An object of class XiMpLe.node.

Note

The <switch> node was introduced with RKWard 0.6.1, please set the dependencies of your component/plugin accordingly.

See Also

rk.XML.connect, rk.XML.convert, rk.XML.external, rk.XML.logic, rk.XML.set, and the Introduction to Writing Plugins for RKWard

Examples

# example for a boolean switch
myCheckbox <- rk.XML.cbox("foo")
rk.XML.switch(myCheckbox, cases=list(
  true=list(fixed_value="foo"),
  false=list(fixed_value="bar"))
)

# example for a case switch
MyRadio <- rk.XML.radio("Chose one",
  options=list(
    "First Option"=c(val="val1"),
    "Second Option"=c(val="val2", chk=TRUE))
)
rk.XML.switch(MyRadio, modifier="string", cases=list(
  case=list(standard="val1", fixed_value="foo"),
  case=list(standard="val2", fixed_value="bar"))
)

rkward-community/rkwarddev documentation built on May 9, 2022, 3:02 p.m.