Skip to content

Commit

Permalink
Fixed basic menu readme
Browse files Browse the repository at this point in the history
  • Loading branch information
miketheprogrammer committed Nov 12, 2014
1 parent 7beda7d commit 5e300fe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 127 deletions.
44 changes: 14 additions & 30 deletions doc/tutorials/basic_menu/README.md
Expand Up @@ -18,8 +18,7 @@ func main() {
common.InitLogger()
spawn.SetBaseDirectory("./")
spawn.Run()
thrustWindow := window.Window{Url: "http://breach.cc/"}
thrustWindow.Create(nil)
thrustWindow := window.NewWindow("http://breach.cc/", nil)
thrustWindow.Show()
thrustWindow.Maximize()
thrustWindow.Focus()
Expand All @@ -35,41 +34,38 @@ We need to add the following import.

Next lets make our top level menus
Note all the following code comes before
the call to dispatcher.RunLoop
the call to dispatcher.RunLoop, It doesnt have to, you can run dispatcher runloop whenever you want, but it will block the process.

As long as you have something blocking the main thread from exiting the process will stay open.

for instance the following pseudo code.
http.server.start()
go createApplicationMenu()
go dispatcher.RunLoop()

Anyway lets proceed

```go

// make our top menus
//applicationMenu, is essentially the menu bar
applicationMenu := menu.Menu{}
applicationMenu := menu.NewMenu()
//applicationMenuRoot is the first menu, on darwin this is always named the name of your application.
applicationMenuRoot := menu.Menu{}
applicationMenuRoot := menu.NewMenu()
//File menu is our second menu
fileMenu := menu.Menu{}
fileMenu := menu.NewMenu()

```

As you may have noticed by now every item has a Create all. We need to execute those calls in the next snippet, however you may be asking why it is not automatically done in the constructor? Create actually makes a JSONRPC call to Thrust Core to create an object of that type on the heap. This is often what you want, but not always, sometimes you may want to prebuild the model here, and then create it.

Lets now create our menu bar, and the base application root menu.
```go

// Create our menu bar
applicationMenu.Create()

// Lets build our root menu.
applicationMenuRoot.Create()

applicationMenuRoot.AddItem(1, "About")

```

Now the same goes for our File menu

```go

// Now for the File menu
fileMenu.Create()
fileMenu.AddItem(2, "Open")
fileMenu.AddItem(3, "Edit")
fileMenu.AddSeparator()
Expand All @@ -90,18 +86,6 @@ Keep in mind, on darwin systems the first menu attached to the top level menu(me

In our case the default name is Go Thrust

Remember how in basic_browser, Window automatically self registered with the dispatcher.
unfortunately we have no such luck here.
I suppose this method could be added as an effect of SetApplicationMenu, but the effects of that need to be
Ironed out.
However, as least we only need to register the top level menu for events, all sub menus will delegate for the top menu.

```go

dispatcher.RegisterHandler(applicationMenu.DispatchResponse)

```

Now we just set the application menu and run the loop

```go
Expand Down
97 changes: 0 additions & 97 deletions doc/tutorials/basic_menu/basic_menu.md

This file was deleted.

0 comments on commit 5e300fe

Please sign in to comment.