mirror of
https://github.com/VladimirMarkelov/clui.git
synced 2025-04-28 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
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -208,6 +208,8 @@ const (
|
||||
EventChanged
|
||||
// Button event - button was clicked
|
||||
EventClicked
|
||||
// dialog closed
|
||||
EventDialogClose
|
||||
// Close application
|
||||
EventQuit
|
||||
)
|
||||
|
@ -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)
|
||||
|
10
window.go
10
window.go
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user