Skip to content

Commit 8894555

Browse files
committed
Control tab support
1 parent 122881a commit 8894555

File tree

8 files changed

+200
-40
lines changed

8 files changed

+200
-40
lines changed

.vs/MathCATForPython/v17/.suo

8 KB
Binary file not shown.

.vs/VSWorkspaceState.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
{
22
"ExpandedNodes": [
3-
"",
4-
"\\NVDA-addon",
5-
"\\NVDA-addon\\addon",
6-
"\\NVDA-addon\\addon\\globalPlugins",
7-
"\\NVDA-addon\\addon\\globalPlugins\\MathCAT"
3+
""
84
],
9-
"SelectedNode": "\\NVDA-addon\\addon\\globalPlugins\\MathCAT\\MathCATgui.py",
5+
"SelectedNode": "\\C:\\Users\\Rorme\\Source\\Repos\\NSoiffer\\MathCATForPython",
106
"PreviewInSolutionExplorer": false
117
}

.vs/slnx.sqlite

0 Bytes
Binary file not shown.

.vscode/launch.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python: Current File",
9+
"type": "python",
10+
"request": "launch",
11+
"program": "${file}",
12+
"console": "integratedTerminal",
13+
"justMyCode": true
14+
}
15+
]
16+
}

NVDA-addon/addon/globalPlugins/MathCAT/MathCATPreferences.py

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ def load_user_preferences():
5656
global user_preferences
5757
#merge user file values into the user preferences data structure
5858
if os.path.exists(path_to_user_preferences()):
59-
with open(path_to_user_preferences()) as f:
59+
with open(path_to_user_preferences(), encoding='utf-8') as f:
6060
# merge with the default preferences, overwriting with the user's values
6161
user_preferences |= yaml.load(f, Loader=yaml.FullLoader)
6262

6363
def write_user_preferences():
6464
if not os.path.exists(path_to_user_preferences_folder()):
6565
#create a folder for the user preferences
6666
os.mkdir(path_to_user_preferences_folder())
67-
with open(path_to_user_preferences(), 'w') as f:
67+
with open(path_to_user_preferences(), 'w', encoding="utf-8") as f:
6868
#write values to the user preferences file, NOT the default
69-
yaml.dump(user_preferences, f)
69+
yaml.dump(user_preferences, stream=f, allow_unicode=True)
7070

7171
class UserInterface(MathCATgui.MathCATPreferencesDialog):
7272
def GetLanguages(self):
@@ -106,6 +106,7 @@ def set_ui_values(self):
106106
#now get the available SpeechStyles from the folder structure and set to the preference setting is possible
107107
UserInterface.GetSpeechStyles(self, user_preferences["Speech"]["SpeechStyle"])
108108
self.m_choiceSpeechAmount.SetSelection(Speech_Verbosity.index(user_preferences["Speech"]["Verbosity"]))
109+
self.m_sliderRelativeSpeed.SetValue(user_preferences["Speech"]["MathRate"])
109110
self.m_choiceSpeechForChemical.SetSelection(Speech_Chemistry.index(user_preferences["Speech"]["Chemistry"]))
110111
self.m_choiceNavigationMode.SetSelection(Navigation_NavMode.index(user_preferences["Navigation"]["NavMode"]))
111112
self.m_checkBoxResetNavigationMode.SetValue(user_preferences["Navigation"]["ResetNavMode"])
@@ -128,6 +129,7 @@ def get_ui_values(self):
128129
user_preferences["Speech"]["Language"] = self.m_choiceLanguage.GetStringSelection()
129130
user_preferences["Speech"]["SpeechStyle"] = self.m_choiceSpeechStyle.GetStringSelection()
130131
user_preferences["Speech"]["Verbosity"] = Speech_Verbosity[self.m_choiceSpeechAmount.GetSelection()]
132+
user_preferences["Speech"]["MathRate"] = self.m_sliderRelativeSpeed.GetValue()
131133
user_preferences["Speech"]["Chemistry"] = Speech_Chemistry[self.m_choiceSpeechForChemical.GetSelection()]
132134
user_preferences["Navigation"]["NavMode"] = Navigation_NavMode[self.m_choiceNavigationMode.GetSelection()]
133135
user_preferences["Navigation"]["ResetNavMode"] = self.m_checkBoxResetNavigationMode.GetValue()
@@ -193,8 +195,30 @@ def MathCATPreferencesDialogOnCharHook(self,event):
193195
UserInterface.OnClickCancel(self,event)
194196
if keyCode == wx.WXK_RETURN:
195197
UserInterface.OnClickOK(self,event)
196-
#if keyCode == wx.WXK_TAB and wx.KeyboardState.GetModifiers():
197-
# print("Tab")
198+
if keyCode == wx.WXK_TAB and (event.GetModifiers() == wx.MOD_CONTROL):
199+
#cycle the category forward
200+
new_category = self.m_listBoxPreferencesTopic.GetSelection() + 1
201+
if new_category == 3:
202+
new_category = 0
203+
self.m_listBoxPreferencesTopic.SetSelection(new_category)
204+
#update the ui to show the new page
205+
UserInterface.OnListBoxCategories(self,event)
206+
#set the focus into the category list box
207+
self.m_listBoxPreferencesTopic.SetFocus()
208+
#jump out so the tab key is not processed
209+
return
210+
if keyCode == wx.WXK_TAB and (event.GetModifiers() == wx.MOD_CONTROL|wx.MOD_SHIFT):
211+
#cycle the category back
212+
new_category = self.m_listBoxPreferencesTopic.GetSelection() - 1
213+
if new_category == -1:
214+
new_category = 2
215+
self.m_listBoxPreferencesTopic.SetSelection(new_category)
216+
#update the ui to show the new page
217+
UserInterface.OnListBoxCategories(self,event)
218+
#update the ui to show the new page
219+
self.m_listBoxPreferencesTopic.SetFocus()
220+
#jump out so the tab key is not processed
221+
return
198222
event.Skip()
199223

200224
app = wx.App(False)

NVDA-addon/addon/globalPlugins/MathCAT/MathCATgui.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
###########################################################################
99

1010
import wx
11-
# from . import xrc
11+
import wx.xrc
1212

1313
import gettext
1414
_ = gettext.gettext
@@ -116,6 +116,19 @@ def __init__( self, parent ):
116116

117117
bSizer121.Add( bSizer71, 1, wx.EXPAND, 5 )
118118

119+
bSizer7131 = wx.BoxSizer( wx.HORIZONTAL )
120+
121+
self.m_staticText21111 = wx.StaticText( self.m_panelSpeech, wx.ID_ANY, _(u"Relative speed:"), wx.DefaultPosition, wx.DefaultSize, 0 )
122+
self.m_staticText21111.Wrap( -1 )
123+
124+
bSizer7131.Add( self.m_staticText21111, 0, wx.ALL, 5 )
125+
126+
self.m_sliderRelativeSpeed = wx.Slider( self.m_panelSpeech, wx.ID_ANY, 100, 10, 1000, wx.DefaultPosition, wx.DefaultSize, wx.SL_HORIZONTAL )
127+
bSizer7131.Add( self.m_sliderRelativeSpeed, 0, wx.ALL, 5 )
128+
129+
130+
bSizer121.Add( bSizer7131, 1, wx.EXPAND, 5 )
131+
119132
bSizer712 = wx.BoxSizer( wx.HORIZONTAL )
120133

121134
self.m_staticText411 = wx.StaticText( self.m_panelSpeech, wx.ID_ANY, _(u"Subject area to be used when it cannot be determined automatically:"), wx.DefaultPosition, wx.DefaultSize, 0 )
@@ -147,12 +160,6 @@ def __init__( self, parent ):
147160
bSizer121.Add( bSizer711, 1, wx.EXPAND, 5 )
148161

149162

150-
bSizer121.Add( ( 0, 0), 1, wx.EXPAND, 5 )
151-
152-
153-
bSizer121.Add( ( 0, 0), 1, wx.EXPAND, 5 )
154-
155-
156163
self.m_panelSpeech.SetSizer( bSizer121 )
157164
self.m_panelSpeech.Layout()
158165
bSizer121.Fit( self.m_panelSpeech )

0 commit comments

Comments
 (0)