(&self)
| 986 | } |
| 987 | |
| 988 | fn capture(&self) { |
| 989 | let mut comp = self.as_ref().borrow_mut(); |
| 990 | |
| 991 | assert!( |
| 992 | !comp.destroyed, |
| 993 | "Widget was already destroyed but is being interacted with" |
| 994 | ); |
| 995 | |
| 996 | if let Some(canvas) = comp.canvas.as_ref() { |
| 997 | if canvas.id() == self.id() { |
| 998 | return; |
| 999 | } |
| 1000 | } |
| 1001 | |
| 1002 | let pre = if let Some(canvas) = comp.canvas.as_ref() { |
| 1003 | if let Some(captured) = canvas.captured { |
| 1004 | captured == self.id() |
| 1005 | } else { |
| 1006 | false |
| 1007 | } |
| 1008 | } else { |
| 1009 | false |
| 1010 | }; |
| 1011 | |
| 1012 | if let Some(canvas) = comp.canvas.as_mut() { |
| 1013 | canvas.captured = Some(self.id()); |
| 1014 | } |
| 1015 | |
| 1016 | if !pre && comp.oncaptured.is_some() { |
| 1017 | let _ = comp.oncaptured.get().try_send(true); |
| 1018 | } |
| 1019 | } |
| 1020 | |
| 1021 | fn uncapture(&self) { |
| 1022 | let mut comp = self.as_ref().borrow_mut(); |
no test coverage detected