refactor(scrollbar): make scrollbar event source optional
This commit is contained in:
parent
d4019d00b2
commit
78e1951407
1 changed files with 3 additions and 2 deletions
|
@ -27,10 +27,11 @@ active: bool = false,
|
||||||
|
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
|
||||||
pub fn create(a: Allocator, parent: Widget, event_source: Widget) !Widget {
|
pub fn create(a: Allocator, parent: Widget, event_source: ?Widget) !Widget {
|
||||||
const self: *Self = try a.create(Self);
|
const self: *Self = try a.create(Self);
|
||||||
self.* = try init(parent);
|
self.* = try init(parent);
|
||||||
try event_source.subscribe(EventHandler.bind(self, handle_event));
|
if (event_source) |source|
|
||||||
|
try source.subscribe(EventHandler.bind(self, handle_event));
|
||||||
return self.widget();
|
return self.widget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue