Adding support for ctrl+backspace in searchbars

This commit is contained in:
Jonah Jolley
2019-02-21 00:28:21 -07:00
parent 0dfe6707a7
commit a5a9dc0877
3 changed files with 33 additions and 3 deletions

View File

@@ -6,3 +6,23 @@ def YesNoDialog(question='Are you sure you want to do this?', caption='Yes or no
result = dlg.ShowModal() == wx.ID_YES
dlg.Destroy()
return result
def HandleCtrlBackspace(textControl):
"""
Handles the behavior of Windows ctrl+space
deletes everything from the cursor to the left,
up to the next whitespace.
"""
curPos = textControl.GetInsertionPoint()
searchText = textControl.GetValue()
foundChar = False
for startIndex in range(curPos, -1, -1):
if startIndex - 1 < 0:
break
if searchText[startIndex - 1] != " ":
foundChar = True
elif foundChar:
break
textControl.Remove(startIndex, curPos)
textControl.SetInsertionPoint(startIndex)