mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +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:
+13
-1
@@ -22,7 +22,9 @@ type Context struct {
|
||||
Constraints Constraints
|
||||
|
||||
Config system.Config
|
||||
Queue event.Queue
|
||||
// By convention, a nil Queue is a signal to widgets to draw themselves
|
||||
// in a disabled state.
|
||||
Queue event.Queue
|
||||
*op.Ops
|
||||
}
|
||||
|
||||
@@ -71,3 +73,13 @@ func (c Context) Events(k event.Tag) []event.Event {
|
||||
}
|
||||
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