From 0a1944ef80fc93d2e4f6ffa99446e6b6352e0abc Mon Sep 17 00:00:00 2001 From: cuu Date: Fri, 10 Aug 2018 12:30:16 +0800 Subject: [PATCH] create events under UI --- main.go | 6 ++++-- sysgo/UI/events.go | 6 ++++++ sysgo/UI/main_screen.go | 2 +- test.go | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 sysgo/UI/events.go diff --git a/main.go b/main.go index c250529..ef06171 100644 --- a/main.go +++ b/main.go @@ -46,7 +46,9 @@ func run() int { UI.SwapAndShow() fmt.Println(main_screen) - + + event.AddCustomEvent(UI.RUNEVT) + running := true for running { ev := event.Wait() @@ -65,7 +67,7 @@ func run() int { }else if ev.Data["Key"] == "D" { time.Delay(1000) }else if ev.Data["Key"] == "P" { - event.Post(event.RUNEVT,"GODEBUG=cgocheck=0 sucks") // just id and string, simpify the stuff + event.Post(UI.RUNEVT,"GODEBUG=cgocheck=0 sucks") // just id and string, simpify the stuff }else { main_screen.KeyDown(ev) diff --git a/sysgo/UI/events.go b/sysgo/UI/events.go new file mode 100644 index 0000000..d31d25c --- /dev/null +++ b/sysgo/UI/events.go @@ -0,0 +1,6 @@ +package UI + + +const ( + RUNEVT=1 +) diff --git a/sysgo/UI/main_screen.go b/sysgo/UI/main_screen.go index 05b6737..85f991f 100644 --- a/sysgo/UI/main_screen.go +++ b/sysgo/UI/main_screen.go @@ -393,7 +393,7 @@ func (self *MainScreen) RunEXE( cmdpath string) { cmdpath = strings.Trim(cmdpath," ") cmdpath = CmdClean(cmdpath) - event.Post(event.RUNEVT,cmdpath) + event.Post(RUNEVT,cmdpath) } diff --git a/test.go b/test.go index 74eeb73..a8446e8 100644 --- a/test.go +++ b/test.go @@ -106,7 +106,7 @@ func run() int { time.Delay(1000) } if ev.Data["Key"] == "P" { - event.Post(event.RUNEVT,"GODEBUG=cgocheck=0 sucks") // just id and string, simpify the stuff + event.Post(event.RUNEVT,"GODEBUG=cgocheck=0 sucks") // just id and string, simplify the stuff } } }