Added a general "SetFocus" to Element as a "catch all". Utilizes .Widget so hope they all are being set. Added 'Elem' shortcut for FindElement.

This commit is contained in:
MikeTheWatchGuy 2019-07-31 13:29:03 -04:00
parent b6709c7035
commit c48b236bce
1 changed files with 19 additions and 3 deletions

View File

@ -728,6 +728,22 @@ class Element():
"""
self.TooltipObject = ToolTip(self.Widget, text=tooltip_text, timeout=DEFAULT_TOOLTIP_TIME)
def SetFocus(self, force=False):
"""
Sets the current focus to be on this element
:param force: (bool) if True will call focus_force otherwise calls focus_set
"""
try:
if force:
self.Widget.focus_force()
else:
self.Widget.focus_set()
except:
print('Was unable to set focus. The Widget passed in was perhaps not present in this element? Check your elements .Widget property')
def __del__(self):
""" """
try:
@ -5460,9 +5476,9 @@ class Window:
element = ErrorElement(key=key)
return element
Element = FindElement # Shortcut function
Find = FindElement
Element = FindElement # Shortcut function
Find = FindElement # Shortcut function, most likely not used by many people.
Elem = FindElement # NEW for 2019! More laziness... Another shortcut
def FindElementWithFocus(self):
"""