func (this *GUI) showOrHideContainerDependingOnIfElseEval(ifElseStmt interfaces.IfElse, conditionalContainerIfBody, conditionalContainerElseBody *ui.Box) { conditionValue := ifElseStmt.EvalConditionAsBool(this.Symbols) // ifElse if block condition evals to true if conditionValue { conditionalContainerIfBody.Show() conditionalContainerElseBody.Hide() return } // condition evals to false, show else body conditionalContainerIfBody.Hide() conditionalContainerElseBody.Show() }
// VisitIfElse creates questions embedded in an its bodies and registers show/hide callbacks func (this *GUI) VisitIfElse(ifElse interfaces.IfElse, context interface{}) interface{} { guiQuestionsIfBody := handleQuestions(this, ifElse.IfBodyQuestions()) guiQuestionsElseBody := handleQuestions(this, ifElse.ElseBodyQuestions()) ifQuestionsEncompassingContainer := this.GUIForm.createQuestionTable(guiQuestionsIfBody) elseQuestionsEncompassingContainer := this.GUIForm.createQuestionTable(guiQuestionsElseBody) this.registerOnShowCallback(func() { this.GUIForm.addQuestionContainer(ifQuestionsEncompassingContainer) this.GUIForm.addQuestionContainer(elseQuestionsEncompassingContainer) this.showOrHideContainerDependingOnIfElseEval(ifElse, ifQuestionsEncompassingContainer, elseQuestionsEncompassingContainer) }) this.Symbols.RegisterCallback(func() { log.Debug("Received symbols update callback in IfElse") this.showOrHideContainerDependingOnIfElseEval(ifElse, ifQuestionsEncompassingContainer, elseQuestionsEncompassingContainer) }) return nil }