mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-08-09 17:41:14 +10:00
Add font scaling keyboard and mouse shortcuts (#4781)
* Add font scaling shortcuts * Fix font scaling shortcut modifiers --------- Co-authored-by: Chris Titus <contact@christitus.com>
This commit is contained in:
co-authored by
Chris Titus
parent
9fed8d1c4c
commit
29b269201d
@@ -210,6 +210,8 @@ $sync.SearchBarClearButton.Add_Click({
|
|||||||
})
|
})
|
||||||
|
|
||||||
# add some shortcuts for people that don't like clicking
|
# add some shortcuts for people that don't like clicking
|
||||||
|
function Invoke-WinUtilFontScaleStep([double]$Step) { $sync.FontScalingSlider.Value = [math]::Max(0.75, [math]::Min(2.0, $sync.FontScalingSlider.Value + $Step)); Invoke-WinUtilFontScaling -ScaleFactor $sync.FontScalingSlider.Value }
|
||||||
|
|
||||||
$commonKeyEvents = {
|
$commonKeyEvents = {
|
||||||
# Prevent shortcuts from executing if a process is already running
|
# Prevent shortcuts from executing if a process is already running
|
||||||
if ($sync.ProcessRunning -eq $true) {
|
if ($sync.ProcessRunning -eq $true) {
|
||||||
@@ -233,13 +235,25 @@ $commonKeyEvents = {
|
|||||||
}
|
}
|
||||||
# Handle Ctrl key combinations for specific actions
|
# Handle Ctrl key combinations for specific actions
|
||||||
if ($_.KeyboardDevice.Modifiers -eq "Ctrl") {
|
if ($_.KeyboardDevice.Modifiers -eq "Ctrl") {
|
||||||
|
$keyEventArgs = $_
|
||||||
switch ($_.Key) {
|
switch ($_.Key) {
|
||||||
"F" { $sync.SearchBar.Focus() } # Focus on the search bar
|
"F" { $sync.SearchBar.Focus() } # Focus on the search bar
|
||||||
"Q" { $this.Close() } # Close the application
|
"Q" { $this.Close() } # Close the application
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$ctrlShiftModifiers = [Windows.Input.ModifierKeys]::Control -bor [Windows.Input.ModifierKeys]::Shift
|
||||||
|
if ($_.KeyboardDevice.Modifiers -eq "Ctrl" -or $_.KeyboardDevice.Modifiers -eq $ctrlShiftModifiers) {
|
||||||
|
$keyEventArgs = $_
|
||||||
|
switch ($_.Key) {
|
||||||
|
{ $_ -in "OemPlus", "Add" } { Invoke-WinUtilFontScaleStep 0.05; $keyEventArgs.Handled = $true }
|
||||||
|
{ $_ -in "OemMinus", "Subtract" } { Invoke-WinUtilFontScaleStep -0.05; $keyEventArgs.Handled = $true }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$sync["Form"].Add_PreViewKeyDown($commonKeyEvents)
|
$sync["Form"].Add_PreViewKeyDown($commonKeyEvents)
|
||||||
|
$sync["Form"].Add_PreviewMouseWheel({
|
||||||
|
if ([Windows.Input.Keyboard]::Modifiers -eq "Ctrl") { Invoke-WinUtilFontScaleStep $(if ($_.Delta -gt 0) { 0.05 } else { -0.05 }); $_.Handled = $true }
|
||||||
|
})
|
||||||
|
|
||||||
$sync["Form"].Add_MouseLeftButtonDown({
|
$sync["Form"].Add_MouseLeftButtonDown({
|
||||||
Invoke-WPFPopup -Action "Hide" -Popups @("Settings", "Theme", "FontScaling")
|
Invoke-WPFPopup -Action "Hide" -Popups @("Settings", "Theme", "FontScaling")
|
||||||
|
|||||||
Reference in New Issue
Block a user