mirror of
https://github.com/VladimirMarkelov/clui.git
synced 2025-04-30 13:48:50 +08:00
closes #8 - modality
This commit is contained in:
parent
20fd6ab608
commit
30d8edcb20
10
composer.go
10
composer.go
@ -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)
|
||||||
|
@ -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
|
||||||
)
|
)
|
||||||
|
@ -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)
|
||||||
|
10
window.go
10
window.go
@ -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
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user