How to tell if DirectEntry has focus?

Trying to create a way to tab between my Entrys.

  def __Main(self):
    for x in self.ObjectList:
      if x['focus']:
        Number = self.ObjectList.index(x)
        print Number
#    if Number >= len(self.ObjectList)-1:
#      Number = -1
#    self.ObjectList[Number+1]['focus']=1

Running this I end up with it only printing the 1st object that I set focus to. When I click on other Entrys, it doesn’t print a number… How do you get the current focus item? Aka, how do you know if a object has focus?

The object will have focus when the blinking ‘|’ is visible and if you press a letter it will type in the entry.


Oh yeah. If you want to have that function always checking/printing what gui object is in focus, make sure it’s a task.

Huh? lol o.o;

Not what I mean xD Code wise… how does it know it has focus ^^; Simply calling x[focus] will return 0 even if the object has focus when I click on it.

Btw, you don’t need to have task for everything you know :slight_smile:

I used this keywords in DE constructor to store information about “focused” element: focusInCommand, focusInExtraArgs, focusOutCommand, focusOutExtraArgs.

Thanks… face plam I should’ve just try adding it as a dic instead… X.x

    object["focusInCommand"] = self.SetFocus
    object["focusInExtraArgs"] = [object]
    object["focusOutCommand"] = self.UnSetFocus
    object["focusOutExtraArgs"] = [object]