Greetings,
I wanted to share that there “will be” changes coming that will really enhance the Material-UI library. Here is a glimpse of the coming changes.
Buttons (all buttons):
- Support multiple states.
- The following states are supported: ‘off’ (normal), ‘on’ (pressed/touching) or ‘disabled’ (non-functional).
- Each state supports setting colors or changing the image for the button, calling a method and passing data to that method.
- The callBack for successful “touch” will not be called if you ‘move’ away from the button and let go. Or move over another button you will not affect that other button’s events.
- Supported visual representations are: text (material font icons), SVG (scalable vector graphics, single and multi-color), images (jpg, png).
- SVG’s with a single color can be re-colored by setting the fillColor in the state for svg.
- There is an order of precedence when specifying text, SVG or image. Order is SVG, Image and Text. If you specify text and SVG then SVG is used.
- Helper method to set button to each state. Let’s say you ‘disabled’ the button. During execution of the App you can call a method to change the state of the button at any time.
Example usage with newIconButton(…):
local buttonMessage = function( event ) local callBackData = mui.getEventParameter(event, "muiTargetCallBackData") if callBackData ~= nil then print("Button message: "..callBackData.message) end end mui.newIconButton({ parent = mui.getParent(), name = "plus", text = "help", width = 25, height = 25, x = 30, y = 30, font = mui.materialFont, state = { value = "disabled", -- specify the state to be in when button is created off = { textColor = { 0.25, 0.75, 1, 1 }, callBack = buttonMessage, callBackData = { message = "button is turned off" } --[[-- svg = { path = "ic\_help\_48px.svg", fillColor = { 0.25, 0.75, 1, 1 }, } --]]-- }, on = { textColor = { 1, 0, 0, 1 }, callBack = buttonMessage, callBackData = { message = "button is turned on" } --[[-- svg = { path = "ic\_help\_48px.svg", fillColor = { 1, 0, 0, 1 }, } --]]-- }, disabled = { textColor = { 0.5, 0.5, 0.5, 1 }, callBack = buttonMessage, callBackData = { message = "button is disabled" } --[[-- svg = { path = "ic\_help\_48px.svg", fillColor = { 0.5, 0.5, 0.5, 1 }, } --]]-- } }, callBack = mui.actionSwitchScene, callBackData = { sceneDestination = "onboard", sceneTransitionColor = { 0.08, 0.9, 0.31 } } })