Multiline editable text for behaviors
by Joe Rossi · in Torque Game Builder · 01/24/2008 (10:38 pm) · 1 replies
I'd like to see more widgets for Behavior fields. I think a multiline editable textbox could be useful for adding things like snippets of code to run on an event, or any long strings.
I tried to hack it in, I got pretty close but I can't get it to update correctly. It also has no undo. If someone who knows the TGE GUI system could fix this up I think it'd be a nice addition to the behaviors.
Here's what I have so far, add this to your tools\behaviorEditor\Scripts\fieldtypes.ed.cs
I tried to hack it in, I got pretty close but I can't get it to update correctly. It also has no undo. If someone who knows the TGE GUI system could fix this up I think it'd be a nice addition to the behaviors.
Here's what I have so far, add this to your tools\behaviorEditor\Scripts\fieldtypes.ed.cs
function QuickEditCodeBoxEdit::setProperty(%this, %object){
%this.text = QuickEditField::getObjectValue( %this, %object );
}
Torque Owner Joe Rossi
Indri Games
function QuickEditCodeBoxEdit::updateProperty(%this, %object){ QuickEditField::updateProperty( %this, %object, %this.text ); } function LBQuickEditContent::createcodeBoxText( %this, %accessor, %label, %tooltip ){ %container = new GuiControl() { canSaveDynamicFields = "0"; Profile = "EditorContainerProfile"; HorizSizing = "right"; VertSizing = "bottom"; Position = "100 3"; Extent = "200 100"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; hovertime = "100"; }; %r = new GuiScrollCtrl( ) { profile = "GuiScrollProfile"; horizSizing = "right"; vertSizing = "bottom"; position = "100 3"; extent = "200 100"; minExtent = "8 2"; visible = "1"; willFirstRespond = "1"; hScrollBar = "alwaysOn"; vScrollBar = "alwaysOn"; constantThumbHeight = "0"; childMargin = "0 0"; }; %editControl = new GuiMLTextEditCtrl( ) { class = QuickEditCodeBoxEdit ; profile = "EditorTextEdit"; tooltipProfile = "EditorToolTipProfile"; canSaveDynamicFields = "0"; horizSizing = "right"; vertSizing = "bottom"; position = "100 3"; extent = "200 100"; minExtent = "8 8"; visible = "1"; helpTag = "0"; lineSpacing = "2"; allowColorChars = "0"; maxChars = "-1"; undoLabel = %label; internalName = %accessor @ "codeBox"; sinkAllKeyEvents = "0"; historySize = "0"; canSave = "1"; hovertime = "100"; accessor = %accessor; object = %this.object; useWords = false; }; %labelControl = new GuiTextCtrl() { canSaveDynamicFields = "0"; Profile = "EditorFontHLBold"; HorizSizing = "right"; VertSizing = "bottom"; Position = "16 3"; Extent = "100 18"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; hovertime = "100"; tooltip = %tooltip; tooltipProfile = "EditorToolTipProfile"; text = %label; maxLength = "1024"; }; %editControl.setProperty(%this.object); %editControl.altCommand = "ToolManager.getLastWindow().setFirstResponder(); " @ %editControl @ ".updateProperty(" @ %editControl @ ".object" @ ");"; %editControl.validate = %editControl @ ".updateProperty(" @ %editControl @ ".object" @ ");"; %r.add( %editControl ); %container.add( %r ) %container.add( %labelControl ); %this.addProperty( %editControl ); %this.add( %container ); return %container; } BehaviorEditor::registerFieldType("codeBox", "createcodeBox"); function BehaviorFieldStack::createcodeBox(%this, %behavior, %fieldIndex ){ %fieldInfo = %behavior.template.getBehaviorField( %fieldIndex ); %name = getField( %fieldInfo, 0 ); %description = %behavior.template.getBehaviorFieldDescription( %fieldIndex ); %control = %this.createcodeBoxText( %name, %name, %description ); %editField = %control.findObjectByInternalName( %name @ "codeBox"); %editField.object = %behavior; }