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

View File

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

View File

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

View File

@ -14,6 +14,8 @@ type Window struct {
pack PackType pack PackType
children []Control children []Control
controls []Control controls []Control
// dialog support
modal bool
} }
func NewWindow(parent Screen, x, y, w, h int, title string) *Window { 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 return HitInside
} }
func (w *Window) SetModal(modal bool) {
w.modal = modal
}
func (w *Window) Modal() bool {
return w.modal
}