Add #[inline(always)] to a few things

This commit is contained in:
Emil Ernerfeldt 2021-04-15 10:37:31 +02:00
parent 76d5229821
commit 231c075867
2 changed files with 6 additions and 1 deletions

View file

@ -12,7 +12,7 @@ NOTE: [`eframe`](eframe/CHANGELOG.md), [`egui_web`](egui_web/CHANGELOG.md) and [
* Add `Response::request_focus` and `Response::surrender_focus`.
### Changed 🔧
* Make `Memrory::has_focus` public (again)
* Make `Memory::has_focus` public (again)
### Fixed 🐛
* Fix [defocus-bug on touch screens](https://github.com/emilk/egui/issues/288)

View file

@ -297,12 +297,14 @@ impl Memory {
}
/// Does this widget have keybaord focus?
#[inline(always)]
pub fn has_focus(&self, id: Id) -> bool {
self.interaction.focus.id == Some(id)
}
/// Give keyboard focus to a specific widget.
/// See also [`crate::Response::request_focus`].
#[inline(always)]
pub fn request_focus(&mut self, id: Id) {
self.interaction.focus.id = Some(id);
}
@ -324,14 +326,17 @@ impl Memory {
}
/// Stop editing of active `TextEdit` (if any).
#[inline(always)]
pub fn stop_text_input(&mut self) {
self.interaction.focus.id = None;
}
#[inline(always)]
pub fn is_anything_being_dragged(&self) -> bool {
self.interaction.drag_id.is_some()
}
#[inline(always)]
pub fn is_being_dragged(&self, id: Id) -> bool {
self.interaction.drag_id == Some(id)
}