#72 - introduce public function WindowManager to access internal Composer to call low level function to manipulate Windows

This commit is contained in:
Vladimir Markelov 2018-01-23 13:59:25 -08:00
parent a26503f0f6
commit 0c6821caf3
4 changed files with 17 additions and 11 deletions

View File

@ -4,6 +4,8 @@
[*] Fix TableView scrollbars: both scrollbars did not response mouse clicks
if the last row or column were visible
[*] Fix crash after clicking the first TableView column that shows row numbers
[*] Made function to get internal composer public for low level access to
function that manipulates Windows. Function name is WindowManager
2018-01-13 - version 0.6.4
[*] Add a workaround for 'false' key presses fired after clicking mouse on OSX

View File

@ -35,7 +35,11 @@ func initComposer() {
comp.lastKey = term.KeyEsc
}
func composer() *Composer {
// WindowManager returns main Window manager (that is Composer). Use it at
// your own risk because it provides an access to some low level Window
// manipulations.
// Note: Now it is not thread safe to call Composer methods from a few threads.
func WindowManager() *Composer {
return comp
}

View File

@ -70,7 +70,7 @@ func CreateConfirmationDialog(title, question string, buttons []string, defaultB
btn1 := CreateButton(frm1, AutoSize, AutoSize, bText, Fixed)
btn1.OnClick(func(ev Event) {
dlg.result = DialogButton1
composer().DestroyWindow(dlg.view)
WindowManager().DestroyWindow(dlg.view)
if dlg.onClose != nil {
go dlg.onClose()
}
@ -82,7 +82,7 @@ func CreateConfirmationDialog(title, question string, buttons []string, defaultB
btn2 = CreateButton(frm1, AutoSize, AutoSize, buttons[1], Fixed)
btn2.OnClick(func(ev Event) {
dlg.result = DialogButton2
composer().DestroyWindow(dlg.view)
WindowManager().DestroyWindow(dlg.view)
if dlg.onClose != nil {
go dlg.onClose()
}
@ -93,7 +93,7 @@ func CreateConfirmationDialog(title, question string, buttons []string, defaultB
btn3 = CreateButton(frm1, AutoSize, AutoSize, buttons[2], Fixed)
btn3.OnClick(func(ev Event) {
dlg.result = DialogButton3
composer().DestroyWindow(dlg.view)
WindowManager().DestroyWindow(dlg.view)
if dlg.onClose != nil {
go dlg.onClose()
}
@ -114,7 +114,7 @@ func CreateConfirmationDialog(title, question string, buttons []string, defaultB
if dlg.result == DialogAlive {
dlg.result = DialogClosed
if ev.X != 1 {
composer().DestroyWindow(dlg.view)
WindowManager().DestroyWindow(dlg.view)
}
if dlg.onClose != nil {
go dlg.onClose()
@ -201,7 +201,7 @@ func CreateSelectDialog(title string, items []string, selectedItem int, typ Sele
} else {
dlg.value = dlg.rg.Selected()
}
composer().DestroyWindow(dlg.view)
WindowManager().DestroyWindow(dlg.view)
if dlg.onClose != nil {
go dlg.onClose()
}
@ -212,7 +212,7 @@ func CreateSelectDialog(title string, items []string, selectedItem int, typ Sele
btn2.OnClick(func(ev Event) {
dlg.result = DialogButton2
dlg.value = -1
composer().DestroyWindow(dlg.view)
WindowManager().DestroyWindow(dlg.view)
if dlg.onClose != nil {
go dlg.onClose()
}
@ -224,7 +224,7 @@ func CreateSelectDialog(title string, items []string, selectedItem int, typ Sele
if dlg.result == DialogAlive {
dlg.result = DialogClosed
if ev.X != 1 {
composer().DestroyWindow(dlg.view)
WindowManager().DestroyWindow(dlg.view)
}
if dlg.onClose != nil {
go dlg.onClose()

View File

@ -302,11 +302,11 @@ func (w *Window) SetVisible(visible bool) {
w.hidden = !visible
if w.hidden {
w.SetModal(false)
if composer().topWindow() == w {
composer().moveActiveWindowToBottom()
if WindowManager().topWindow() == w {
WindowManager().moveActiveWindowToBottom()
}
} else {
composer().activateWindow(w)
WindowManager().activateWindow(w)
}
}
}