mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 10:25:37 +00:00
layout: add Disabled method to Context
This adds a simple method that returns a copy of the Context with no event queue. Widgets laid out with this Context will never receive events, and can check whether the event queue is nil as a hint for whether or not to draw themselves as disabled. Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
@@ -22,6 +22,8 @@ type Context struct {
|
|||||||
Constraints Constraints
|
Constraints Constraints
|
||||||
|
|
||||||
Config system.Config
|
Config system.Config
|
||||||
|
// By convention, a nil Queue is a signal to widgets to draw themselves
|
||||||
|
// in a disabled state.
|
||||||
Queue event.Queue
|
Queue event.Queue
|
||||||
*op.Ops
|
*op.Ops
|
||||||
}
|
}
|
||||||
@@ -71,3 +73,13 @@ func (c Context) Events(k event.Tag) []event.Event {
|
|||||||
}
|
}
|
||||||
return c.Queue.Events(k)
|
return c.Queue.Events(k)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disabled returns a copy of this context with a nil Queue,
|
||||||
|
// blocking events to widgets using it.
|
||||||
|
//
|
||||||
|
// By convention, a nil Queue is a signal to widgets to draw themselves
|
||||||
|
// in a disabled state.
|
||||||
|
func (c Context) Disabled() Context {
|
||||||
|
c.Queue = nil
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user