Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/SKUI/control.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class Control < Base
# @since 1.0.0
prop_writer( :font_name, :font_size ) # (!) Needs more work.

# @return [String]
# @since 1.0.0
prop( :css_class, &TypeCheck::STRING )

# @return [Rect]
# @since 1.0.0
attr_reader( :rect )
Expand All @@ -57,6 +61,14 @@ def initialize
@rect = Rect.new( self )
end

# Set a custom css class identifier for this control
# @since 1.0.0
def css_class( css_class )
if css_class.is_a? String
@properties[ :css_class ] = css_class
end
end

# Positive `x` value will anchor the control to the left side of the
# container, negative will anchor the control to the right side.
#
Expand Down
5 changes: 5 additions & 0 deletions src/SKUI/js/ui.control.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ function Control( jquery_element ) {
Base.call( this, jquery_element );
}

Control.prototype.set_css_class = function( value ) {
this.control.addClass( value );
return value;
};

Control.prototype.set_disabled = function( value ) {
this.control.toggleClass( 'disabled', value );
this.control.prop( 'disabled', value );
Expand Down