slider: Consider text direction when handling arrow keys
Currently the right arrow key always increases the slider value, even in RTL locales where the slider itself increases leftwards. Fix that, so that the arrow keys always correspond to the direction of the slider. Closes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7963 Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3500>
This commit is contained in:
@ -193,7 +193,9 @@ export const Slider = GObject.registerClass({
|
||||
vfunc_key_press_event(event) {
|
||||
let key = event.get_key_symbol();
|
||||
if (key === Clutter.KEY_Right || key === Clutter.KEY_Left) {
|
||||
let delta = key === Clutter.KEY_Right ? 0.1 : -0.1;
|
||||
const rtl = this.get_text_direction() === Clutter.TextDirection.RTL;
|
||||
const increaseKey = rtl ? Clutter.KEY_Left : Clutter.KEY_Right;
|
||||
const delta = key === increaseKey ? 0.1 : -0.1;
|
||||
this.value = Math.max(0, Math.min(this._value + delta, this._maxValue));
|
||||
return Clutter.EVENT_STOP;
|
||||
}
|
||||
|
Reference in New Issue
Block a user