core: button: allow dragging to a text-only key part

This commit is contained in:
Richard Acayan 2024-08-04 22:12:25 -04:00
parent fc829a96c4
commit 3bb02196db
2 changed files with 9 additions and 4 deletions

View file

@ -349,13 +349,13 @@ impl<D: Display, K: Keyboard> Button<D, K> {
fn update_pressed_part(press: &mut Press, key: &Key, angle: usize) fn update_pressed_part(press: &mut Press, key: &Key, angle: usize)
{ {
if key.parts[ANGLE_PARTS[angle][0]].sym() != Keysym::NoSymbol { if key.parts[ANGLE_PARTS[angle][0]].pressable() {
press.part = ANGLE_PARTS[angle][0]; press.part = ANGLE_PARTS[angle][0];
} else if key.parts[ANGLE_PARTS[angle][1]].sym() != Keysym::NoSymbol { } else if key.parts[ANGLE_PARTS[angle][1]].pressable() {
press.part = ANGLE_PARTS[angle][1]; press.part = ANGLE_PARTS[angle][1];
} else if key.parts[ANGLE_PARTS[angle][2]].sym() != Keysym::NoSymbol { } else if key.parts[ANGLE_PARTS[angle][2]].pressable() {
press.part = ANGLE_PARTS[angle][2]; press.part = ANGLE_PARTS[angle][2];
} else if key.parts[ANGLE_PARTS[angle][3]].sym() != Keysym::NoSymbol { } else if key.parts[ANGLE_PARTS[angle][3]].pressable() {
press.part = ANGLE_PARTS[angle][3]; press.part = ANGLE_PARTS[angle][3];
} }
} }

View file

@ -402,6 +402,11 @@ impl Part {
self.key_avail = self.val.0 != Keysym::NoSymbol && key_supp; self.key_avail = self.val.0 != Keysym::NoSymbol && key_supp;
} }
pub fn pressable(&self) -> bool
{
self.text_avail || self.key_avail
}
pub fn modifier_id(&self) -> usize pub fn modifier_id(&self) -> usize
{ {
match self.val.0 { match self.val.0 {