closes #8 - modality

This commit is contained in:
Vladimir Markelov 2015-10-21 09:38:43 -07:00
parent 20fd6ab608
commit 30d8edcb20
4 changed files with 22 additions and 2 deletions

View File

@ -157,6 +157,10 @@ func (c *Composer) moveActiveWindowToBottom() bool {
return false
}
if c.topView().Modal() {
return false
}
event := Event{Type: EventActivate, X: 0} // send deactivated
c.sendEventToActiveView(event)
@ -313,8 +317,7 @@ func (c *Composer) processKeySeq(ev term.Event) bool {
if c.ctrlKey == term.KeyCtrlW {
switch ev.Key {
case term.KeyCtrlH:
c.moveActiveWindowToBottom()
return true
return c.moveActiveWindowToBottom()
default:
return false
}
@ -361,6 +364,9 @@ func (c *Composer) processMouseClick(ev term.Event) {
}
if c.topView() != view {
if c.topView().Modal() {
return
}
event := Event{Type: EventActivate, X: 0} // send 'deactivated'
c.sendEventToActiveView(event)
c.activateView(view)

View File

@ -208,6 +208,8 @@ const (
EventChanged
// Button event - button was clicked
EventClicked
// dialog closed
EventDialogClose
// Close application
EventQuit
)

View File

@ -53,6 +53,8 @@ type View interface {
Screen() Screen
Parent() Control
HitTest(int, int) HitResult
SetModal(bool)
Modal() bool
Paddings() (int, int, int, int)
SetPaddings(int, int, int, int)

View File

@ -14,6 +14,8 @@ type Window struct {
pack PackType
children []Control
controls []Control
// dialog support
modal bool
}
func NewWindow(parent Screen, x, y, w, h int, title string) *Window {
@ -460,3 +462,11 @@ func (w *Window) HitTest(x, y int) HitResult {
return HitInside
}
func (w *Window) SetModal(modal bool) {
w.modal = modal
}
func (w *Window) Modal() bool {
return w.modal
}