Skip to content

Commit

Permalink
Merge pull request #636 from Shallowmallow/PropertyAction
Browse files Browse the repository at this point in the history
PropertyGrid - Adding back action and toggle
  • Loading branch information
ianharrigan authored Sep 28, 2024
2 parents 463b9a6 + 365ba8f commit a754170
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
62 changes: 62 additions & 0 deletions haxe/ui/containers/properties/PropertyEditor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import haxe.ui.components.NumberStepper;
import haxe.ui.components.TextField;
import haxe.ui.components.popups.ColorPickerPopup;
import haxe.ui.data.DataSource;
import haxe.ui.events.MouseEvent;
import haxe.ui.events.UIEvent;
import haxe.ui.util.Color;
import haxe.ui.util.Variant;
Expand Down Expand Up @@ -265,4 +266,65 @@ class PropertyEditorFile extends PropertyEditor {

addComponent(hbox);
}
}


//***********************************************************************************************************
// PropertyEditorAction
//***********************************************************************************************************
class PropertyEditorAction extends PropertyEditor {
private var button:Button;

public function new() {
super();
button = new Button();
button.percentWidth = 100;
addComponent(button);
}

private override function applyProperties(property:Property) {
if (property.text != null) {
button.text = property.text;
}
}

public override function applyValue(value:Variant) {
button.value = value.toString();
}

@:bind(button, MouseEvent.CLICK)
private function onButtonChange(_) {
onValueChanged(button.text);
}
}


//***********************************************************************************************************
// PropertyEditorToggle
//***********************************************************************************************************
class PropertyEditorToggle extends PropertyEditor {
private var button:Button;

public function new() {
super();
button = new Button();
button.percentWidth = 100;
button.toggle = true;
addComponent(button);
}

private override function applyProperties(property:Property) {
if (property.text != null) {
button.text = property.text;
}
}

public override function applyValue(value:Variant) {
button.selected = value.toBool();
}

@:bind(button, UIEvent.CHANGE)
private function onButtonChange(_) {
onValueChanged(button.selected);
}
}
2 changes: 2 additions & 0 deletions haxe/ui/containers/properties/PropertyGrid.hx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class PropertyGrid extends ScrollView {
registeredEditors.set("boolean", { editorClass: PropertyEditorBoolean });
registeredEditors.set("file", { editorClass: PropertyEditorFile });
registeredEditors.set("date", { editorClass: PropertyEditorDate });
registeredEditors.set("action", { editorClass: PropertyEditorAction });
registeredEditors.set("toggle", { editorClass: PropertyEditorToggle });
}

public static function getRegisteredEditorInfo(type:String):RegisteredEditorEntry {
Expand Down

0 comments on commit a754170

Please sign in to comment.