About Monkey 2 › Forums › Monkey 2 Code Library › Mojox GUI Components
This topic contains 2 replies, has 1 voice, and was last updated by cocon 11 months, 3 weeks ago.
Viewing 3 posts - 1 through 3 (of 3 total)
-
AuthorPosts
-
January 3, 2018 at 6:17 pm #12606
Here will be a collection of GUI components for the MojoX GUI system.
January 3, 2018 at 6:23 pm #12607Here is a component that combines a scroll bar and a label.
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142Class LabelScrollbar Extends DockableViewField Caption:StringField Label:LabelField Scrollbar:ScrollBarField OnValueChanged:Void(value:Int)Property Value:Int()Return Scrollbar.ValueEndMethod New(caption:String, value:Int, min:Int, max:Int)Scrollbar = New ScrollBarScrollbar.Minimum = minScrollbar.Maximum = maxScrollbar.Value = valueScrollbar.ValueChanged = UpdateScrollbarLabel = New LabelCaption = captionUpdateLabel()AddView(Label, "top")AddView(Scrollbar, "top")EndPrivateMethod UpdateScrollbar(value:Int)UpdateLabel()OnValueChanged(value)EndMethod UpdateLabel()Label.Text = Caption + ": " + Scrollbar.ValueEndEndMonkey1234567891011Local radius := New LabelScrollbar("Radius", gProperties.ToolSpray_Radius, 1, 500)radius.OnValueChanged = Lambda(value:Int)gProperties.ToolSpray_Radius = valueEndLocal density := New LabelScrollbar("Density", gProperties.ToolSpray_Density, 1, 500)density.OnValueChanged = Lambda(value:Int)gProperties.ToolSpray_Density = valueEndAddView(radius, "top")AddView(density, "top")Attachments:
March 4, 2018 at 4:15 pm #13859Since I wanted to try writing a console based application and I could not figure out the input streams I did this.
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105#Import "<std>"#Import "<mojo>"#Import "<mojox>"Using std..Using mojo..Using mojox..Class Console AbstractPublicFunction Create()Instance = New ConsoleClassEndGlobal ReadLineCallback:Void(input:String)Function Write(text:String)Instance.Write(text)EndFunction WriteLine(text:String)Instance.WriteLine(text)EndPrivateGlobal Instance : ConsoleClassClass ConsoleClass Extends WindowPrivateField textInput : TextFieldField textOutput : TextViewPublicMethod ClearOutput()textOutput.Clear()EndMethod ClearInput()textInput.Clear()EndMethod Write(text:String)textOutput.AppendText(text)EndMethod WriteLine(text:String)textOutput.AppendText(text + "~n")EndMethod New()Super.New("Monkey2 Console", 640, 480, WindowFlags.Resizable)textInput = New TextFieldtextOutput = New TextViewtextInput.Entered = Lambda()If Console.ReadLineCallback <> NullConsole.ReadLineCallback(textInput.Text)textInput.Clear()EndEndLocal label := New Labellabel.Text = "Input: "label.AddView(textInput)Local dockingView := New DockingViewdockingView.AddView(label , "top", "10%")dockingView.AddView(textOutput, "bottom", "90%")ContentView = dockingViewEndEndEndFunction GetCommandResult:String(command:String)Select commandCase "help"Local output := ""output += "Available Commands~n"output += "~qhelp~q, ~qhello~q, ~qquick math~q"Return outputCase "hello"Return "Hello There"Case "quick math"Return "two plus two is four, minus one is three"EndReturn NullEndFunction SetupCommands()Console.WriteLine("Type ~qhelp~q for more information.")Console.ReadLineCallback = Lambda(input:String)Local result := GetCommandResult(input)If result = Null Then result = "Command not identified."Console.WriteLine(result)EndEndFunction Main()New AppInstanceConsole.Create()SetupCommands()App.Run()End -
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.