About Monkey 2 › Forums › Monkey 2 Programming Help › GUI and GameWindow
This topic contains 2 replies, has 2 voices, and was last updated by
cocon 1 year, 3 months ago.
-
AuthorPosts
-
December 22, 2017 at 1:23 pm #12413
How to have the main window split so the left can contain buttons and the other be used for drawing?
December 22, 2017 at 4:34 pm #12414Look at DockingView, it’s one of powerful views.
You can use it to split any area by parts.
Then assign that dock as window.ContentView.
Monkey12345678910Local dock:=New DockingViewLocal canvas:=New LabelLocal uiDock:=New DockingViewLocal uiEdit:=New TextFieldLocal uiButton:=New Button( "Run" )uiDock.AddView( uiEdit,"top" )uiDock.AddView( uiButton,"top" )dock.AddView( uiDock,"right" )dock.ContentView=canvaswindow.ContentView=dockCanvas is label here, but you should to make own class that extends View (inner window class as a variant) and to delegate drawing to it.
For testing bounds you can set backgroundcolor property of your view via view.Style.BackgroundColor=…
And look at docs of view.Layout property, Layout=”fill” is good to have when view became contentView.
December 23, 2017 at 4:44 pm #12427OK I figured out.
If anyone is interested to use it, perhaps to be added in the mojox tests.
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051Namespace myapp#Import "<std>"#Import "<mojo>"#Import "<mojox>"Using std..Using mojo..Using mojox..Class CanvasView Extends ViewMethod OnRender(canvas:Canvas) Overridecanvas.DrawLine(0, 0, Mouse.X, Mouse.Y)EndMethod OnMouseEvent(event:MouseEvent) OverrideApp.RequestRender()EndEndClass MyWindow Extends WindowField mainDock :DockingViewField toolsDock :DockingViewField canvasView :CanvasViewMethod New()Super.New("Paint Application", 1280, 720)mainDock = New DockingViewtoolsDock = New DockingViewcanvasView = New CanvasViewLocal button := New Button("Button 1")toolsDock.AddView(button, "top")mainDock.AddView(toolsDock, "right", 100)mainDock.ContentView = canvasViewContentView = mainDockEndEndFunction Main()New AppInstanceNew MyWindowApp.Run ()End -
AuthorPosts
You must be logged in to reply to this topic.