Ejemplo n.º 1
0
func (this *GUI) showOrHideContainerDependingOnIfEval(ifStmt interfaces.If, conditionalContainer *ui.Box) {
	conditionValue := ifStmt.EvalConditionAsBool(this.Symbols)

	// if condition evals to true
	if conditionValue {
		conditionalContainer.Show()
		return
	}

	// condition evals to false
	conditionalContainer.Hide()
}
Ejemplo n.º 2
0
// VisitIf creates questions embedded in an its body and registers show/hide callbacks
func (this *GUI) VisitIf(ifStmt interfaces.If, context interface{}) interface{} {
	guiQuestions := handleQuestions(this, ifStmt.Questions())
	questionsEncompassingContainer := this.GUIForm.createQuestionTable(guiQuestions)

	this.registerOnShowCallback(func() {
		this.GUIForm.addQuestionContainer(questionsEncompassingContainer)
		this.showOrHideContainerDependingOnIfEval(ifStmt, questionsEncompassingContainer)
	})

	this.Symbols.RegisterCallback(func() {
		log.Debug("Received symbols update callback in If")
		this.showOrHideContainerDependingOnIfEval(ifStmt, questionsEncompassingContainer)
	})

	return nil
}