Comments (2)
Right now extending components is not designed, but can be done with a little trick.
I will think more about this ability, should be it in Druid or not. Druid prefer composition and customizing components via styles should be enough. If you want replace all buttons, current way is copy button component, rework it and register at druid via druid.register()
. Register can override basic components too.
Trick: for now, you can create subclass from druid component in next-way:
local class = require("druid.system.middleclass")
local button = require("druid.base.button")
local M = class("button_custom", button)
--- Class constructor
function M.initialize(self)
--- Call parent constructor
button.initialize(self)
end
function M.is_enabled(self)
print("Overridden function")
return not self.disabled
end
return M
Thanks for feedback! Issue will be closed after solution for this.
from druid.
I was trying to do it using styles only, but I can't quite figure out how to add some properties to it (for example, save the original node's color so I can manipulate it later).
I wanted to avoid copy/paste of the original button codes, because it pretty much contains the basic functionality already, so for easier code maintenance, I just like to extend it.
Your solution above actually works perfectly for my use case! I set the properties in this new extended component, then use those properties in my new style, without having to mess around further with the original button codes.
Thanks again!
from druid.
Related Issues (20)
- Helper module documentation
- Input component and styles bug
- Bug is new update HOT 3
- Empty lang text translate leads to NAN scale
- Node State Animator
- Remove middleclass
- Lang Text translate update should call on_change HOT 1
- Add Druid UI kit
- Question about StaticGrid:remove() HOT 1
- Slider miss node is enabled check
- Remove druid instance from global pool after final function is invoked
- Need an example for creating custom components HOT 1
- Using a druid component inside a prefab HOT 1
- It Scrolls In Reverse HOT 1
- Can't build without example/assets folder HOT 2
- DynamicGrid.get_all_pos didnt work
- Use python instead of python3 and pip3
- The on_click_disabled function for buttons is never called
- Explanation of input bindings is a bit confusing HOT 4
- How to actually use KEYBOARD_TYPE_PASSWORD
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from druid.