How to retrieve text from a label? #602
-
I'm a bit ashamed to ask this, because it seems rather straighforward, but I don't seem to accomplish to get text from a label. The obvious code would be: but as soon as I use console to display the value of the variable labelText, CTRLR crashes. When I use
I get an error "attempt to call method 'getText' ( a nil value)" It's no problem to set the the text of the label:
So the question is: what am I missing? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 19 replies
-
I did find the answer (and as so many times, provided by dnaldoog!) by searching the old cltrlr site. This is the way the code should look like: the trick is adding "L"! How can one know when to add "L"? |
Beta Was this translation helpful? Give feedback.
-
I regret choosing that username - the spelling of it confuses me too and who can say how one would pronounce it? It’s actually my surname spelt backwards 😂 |
Beta Was this translation helpful? Give feedback.
-
On this topic, it is always interesting to see how others are coding :) I'm for example never using panel:getLabel() and setText()/getText() but always using this, whatever the modulator's type is:
with mod being a variable initialized for each modulator with panel:getModulatorByName(). |
Beta Was this translation helpful? Give feedback.
-
Ctrlr Lua Class Functions
CtrlrModulator: CtrlrLuaModulator.cppclass_<CtrlrModulator, CtrlrLuaObject>("CtrlrModulator")
.def("getValue", &CtrlrModulator::getModulatorValue)
.def("setValue", (void (CtrlrModulator::*)(const int, const bool))&CtrlrModulator::setValue)
.def("setValue", (void (CtrlrModulator::*)(const int, const bool, const bool))&CtrlrModulator::setValue)
.def("setValueMapped", &CtrlrModulator::setValueMapped)
.def("setValueMapped", &CtrlrModulator::setValueMappedCompat)
.def("setValueNonMapped", &CtrlrModulator::setValueNonMapped)
.def("getVstIndex", &CtrlrModulator::getVstIndex)
.def("getMaxModulatorValue", &CtrlrModulator::getMaxModulatorValue)
.def("getMaxMapped", &CtrlrModulator::getMaxMapped)
.def("getMaxNonMapped", &CtrlrModulator::getMaxNonMapped)
.def("getMinMapped", &CtrlrModulator::getMinMapped)
.def("getMinNonMapped", &CtrlrModulator::getMinNonMapped)
.def("getMinModulatorValue", &CtrlrModulator::getMinModulatorValue)
.def("getComponent", &CtrlrModulator::getComponent)
.def("getRestoreState", &CtrlrModulator::getRestoreState)
.def("isRestoring", &CtrlrModulator::getRestoreState)
.def("setRestoreState", &CtrlrModulator::setRestoreState)
.def("getMidiMessage", &CtrlrModulator::getMidiMessagePtr)
.def("getName", &CtrlrModulator::getName)
.def("getValueMapped", &CtrlrModulator::getValueMapped)
.def("getValueNonMapped", &CtrlrModulator::getValueNonMapped)
.def("getModulatorValue", &CtrlrModulator::getModulatorValue)
.def("setModulatorValue", &CtrlrModulator::setModulatorValue)
.def("getLuaName", &CtrlrModulator::getName)
.def("getModulatorName", &CtrlrModulator::getName) CtrlrLuaMultiTimer: CtrlrLuaMultiTimer.cppclass_<CtrlrLuaMultiTimer>("CtrlrLuaMultiTimer")
.def("setCallback", &CtrlrLuaMultiTimer::setCallback)
.def("startTimer", &CtrlrLuaMultiTimer::startTimer)
.def("isRegistered", &CtrlrLuaMultiTimer::isRegistered)
.def("stopTimer", &CtrlrLuaMultiTimer::stopTimer)
.def("isTimerRunning", &CtrlrLuaMultiTimer::isTimerRunning)
.def("getTimerInterval", &CtrlrLuaMultiTimer::getTimerInterval) CtrlrLuaObject: CtrlrLuaObject.cpp class_<CtrlrLuaObject>("CtrlrLuaObject")
.def("getPropertyInt", &CtrlrLuaObject::getPropertyInt)
.def("getPropertyDouble", &CtrlrLuaObject::getPropertyDouble)
.def("getPropertyString", &CtrlrLuaObject::getPropertyString)
.def("setPropertyInt", &CtrlrLuaObject::setPropertyInt)
.def("setPropertyColour", &CtrlrLuaObject::setPropertyColour)
.def("setPropertyDouble", &CtrlrLuaObject::setPropertyDouble)
.def("setPropertyString", &CtrlrLuaObject::setPropertyString)
.def("removeProperty", &CtrlrLuaObject::removeProperty)
.def("setProperty", (void (CtrlrLuaObject::*)(const Identifier &, const var &, const bool))&CtrlrLuaObject::setProperty)
.def("getProperty", &CtrlrLuaObject::getProperty)
.def("getObjectTree", &CtrlrLuaObject::getObjectTree)
]; CtrlrLuaPanel: CtrlrLuaPanel.cppclass_<CtrlrPanel, CtrlrLuaObject>("CtrlrPanel")
.def("getModulatorByName", &CtrlrPanel::getModulator)
.def("getModulator", &CtrlrPanel::getModulator)
.def("getModulatorByIndex", &CtrlrPanel::getModulatorByIndex)
.def("getNumModulators", &CtrlrPanel::getNumModulators)
.def("sendMidiMessageNow", (void (CtrlrPanel::*)(CtrlrMidiMessage &)) &CtrlrPanel::sendMidiNow)
.def("sendMidi", (void (CtrlrPanel::*)(CtrlrMidiMessage &, double)) &CtrlrPanel::sendMidi)
.def("getPanelEditor", &CtrlrPanel::getPanelEditor)
.def("getRestoreState", &CtrlrPanel::getRestoreState)
.def("getBootstrapState", &CtrlrPanel::getBootstrapState)
.def("isRestoring", &CtrlrPanel::getRestoreState)
.def("setRestoreState", &CtrlrPanel::setRestoreState)
.def("getComponent", &CtrlrPanel::getComponent)
.def("getGlobalVariable", &CtrlrPanel::getGlobalVariable)
.def("setGlobalVariable", &CtrlrPanel::setGlobalVariable)
.def("getCanvas", &CtrlrPanel::getCanvas)
.def("getWaveformComponent", &CtrlrPanel::getWaveformComponent)
.def("getWaveform", &CtrlrPanel::getWaveformComponent)
.def("getLabelComponent", &CtrlrPanel::getLabelComponent)
.def("getLabel", &CtrlrPanel::getLabelComponent)
.def("getToggleButtonComponent", &CtrlrPanel::getToggleButtonComponent)
.def("getToggleButton", &CtrlrPanel::getToggleButtonComponent)
.def("getImageButtonComponent", &CtrlrPanel::getImageButtonComponent)
.def("getImageButton", &CtrlrPanel::getImageButtonComponent)
.def("getButtonComponent", &CtrlrPanel::getButtonComponent)
.def("getButton", &CtrlrPanel::getButtonComponent)
.def("getComboComponent", &CtrlrPanel::getComboComponent)
.def("getCombo", &CtrlrPanel::getComboComponent)
.def("getListBoxComponent", &CtrlrPanel::getListBoxComponent)
.def("getListBox", &CtrlrPanel::getListBoxComponent)
.def("getFileListBoxComponent", &CtrlrPanel::getFileListBoxComponent)
.def("getFileListBox", &CtrlrPanel::getFileListBoxComponent)
.def("getSliderComponent", &CtrlrPanel::getSliderComponent)
.def("getSlider", &CtrlrPanel::getSliderComponent)
.def("getFixedImageSliderComponent", &CtrlrPanel::getFixedImageSliderComponent)
.def("getFixedImageSlider", &CtrlrPanel::getFixedImageSliderComponent)
.def("getFixedSliderComponent", &CtrlrPanel::getFixedSliderComponent)
.def("getFixedSlider", &CtrlrPanel::getFixedSliderComponent)
.def("getImageSliderComponent", &CtrlrPanel::getImageSliderComponent)
.def("getImageSlider", &CtrlrPanel::getImageSliderComponent)
.def("getModulatorWithProperty", (CtrlrModulator *(CtrlrPanel::*)(const String &, const int)) &CtrlrPanel::getModulatorWithProperty)
.def("getModulatorWithProperty", (CtrlrModulator *(CtrlrPanel::*)(const String &, const String &)) &CtrlrPanel::getModulatorWithProperty)
.def("getModulatorsWithProperty", &CtrlrPanel::getModulatorsWithPropertyLua)
.def("getModulatorsWildcard", (luabind::object (CtrlrPanel::*)(const String &, const bool))&CtrlrPanel::getModulatorsWildcardLua)
.def("getModulatorsWildcard", (luabind::object (CtrlrPanel::*)(const String &, const String &, const bool))&CtrlrPanel::getModulatorsWildcardLua)
.def("getInputComparator", &CtrlrPanel::getInputComparator)
.def("getModulatorValuesAsData", &CtrlrPanel::getModulatorValuesAsData)
.def("setModulatorValuesFromData", &CtrlrPanel::setModulatorValuesFromData)
.def("getLibrary", &CtrlrPanel::getCtrlrMIDILibrary)
.def("getCtrlrMIDILibrary", &CtrlrPanel::getCtrlrMIDILibrary)
.enum_("CtrlrPanelFileType")
[
value("PanelFileXML", 0),
value("PanelFileXMLCompressed", 1),
value("PanelFileBinary", 2),
value("PanelFileBinaryCompressed", 3),
value("PanelFileExport", 4)
] CtrlrPanelCanvas::wrapForLua : CtrlrLuaPanelCanvas.cppclass_<CtrlrPanelCanvas,Component>("CtrlrPanelCanvas")
.def("getLayerByName", &CtrlrPanelCanvas::getLayerByName)
.def("getLayer", &CtrlrPanelCanvas::getLayer)
.def("getLayerFromArray",&CtrlrPanelCanvas::getLayerFromArray)
.def("getNumLayers",&CtrlrPanelCanvas::getNumLayers)
.def("getLayerName",&CtrlrPanelCanvas::getLayerName) CtrlrPanelCanvasLayer: CtrlrLuaPanelCanvasLayer.cppclass_<CtrlrPanelCanvasLayer, bases<Component, CtrlrLuaObject> >("CtrlrPanelCanvasLayer")
.def("moveUp", &CtrlrPanelCanvasLayer::moveUp)
.def("moveDown", &CtrlrPanelCanvasLayer::moveDown) CtrlrPanelEditor: CtrlrLuaPanelEditor.cppclass_<CtrlrPanelEditor, CtrlrLuaObject>("CtrlrPanelEditor")
.def("getWidth", &CtrlrPanelEditor::getWidth)
.def("getHeight", &CtrlrPanelEditor::getHeight)
.def("getCanvas",&CtrlrPanelEditor::getCanvas) CtrlrLuaUtils: CtrlrLuaUtils.cppclass_<CtrlrLuaUtils>("CtrlrLuaUtils")
.def("unpackDsiData", &CtrlrLuaUtils::unpackDsiData, adopt(result))
.def("packDsiData", &CtrlrLuaUtils::packDsiData, adopt(result))
.def("warnWindow", &CtrlrLuaUtils::warnWindow)
.def("infoWindow", &CtrlrLuaUtils::infoWindow)
.def("questionWindow", &CtrlrLuaUtils::questionWindow)
.def("openFileWindow", &CtrlrLuaUtils::openFileWindow)
.def("saveFileWindow", &CtrlrLuaUtils::saveFileWindow)
.def("getDirectoryWindow", &CtrlrLuaUtils::getDirectoryWindow)
.def("askForTextInputWindow", &CtrlrLuaUtils::askForTextInputWindow)
.def("getMidiInputDevices", &CtrlrLuaUtils::getMidiInputDevices)
.def("getMidiOutputDevices", &CtrlrLuaUtils::getMidiOutputDevices) |
Beta Was this translation helpful? Give feedback.
L calls "luabind" wrapper associated to the component.
this is why in the ctrlr code you have a list of Luabind functions.
For exemple this is the function for the component (slider, button etc)