Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label unfocus not working correctly #42

Open
dumbasaroc opened this issue Sep 2, 2020 · 4 comments
Open

Label unfocus not working correctly #42

dumbasaroc opened this issue Sep 2, 2020 · 4 comments

Comments

@dumbasaroc
Copy link

Another strange occurrence with the Form widget, but in my GUI I have 9 different cells (pictured below), and whenever I click on the form in either Form near the grid of image renders (henceforth called Character Selectors), it won't let me unfocus the Form unless I press Enter. If I double-click anywhere on the window when this occurs, it will highlight whatever's in the Form for some reason.

window

The code for this Form is as follows:

class Form(TextInput):
  class Label(glooey.EditableLabel):
    custom_font_name = "Segoe UI"
    custom_font_size = 10
    custom_color = "#000000"
    custom_selection_color = "#ffffff"
    custom_selection_background_color = "#3390ff"
    custom_padding = 2
    # SIDE_MODE is a global for how large the window is
    if Globals.SIZE_MODE == "1920x1080":
      custom_size_hint = (160, 20)
    else:
      custom_size_hint = (80, 20)

    def on_insert_text(self, start, text):
      self._text = self._layout.document.text
      # Gets a list of buttons from a parent widget
      buttons = self.parent.parent.parent._buttons
      if text != "":
        i = 0
        length = len(self.parent.parent.parent.character_list)
        character_list = self.parent.parent.parent.character_list
        for button in buttons:
          while True:
            if i >= length:
              button.hide()
              break
            character_name = character_list[i]
            if self._text.lower() in character_name.lower():
              button._foreground.set_text(character_name)
              button.unhide()
              i += 1
              break
            i += 1
      else:
        for button in buttons:
          button.hide()

      self.dispatch_event('on_edit_text', self)
    
    def on_delete_text(self, start, text):
      self.on_insert_text(start, text)

  def on_unfocus(self, w):
    # Goes to a parent widget and calls a function based on the form's text
    self.parent.parent.parent.changeCharacter(self._label._text)

...where TextInput is the default custom Form class I created. Any ideas as to what could be causing this?

@kalekundert
Copy link
Contributor

Sorry for the slow reply. I'll try to look at this over the weekend. I might have introduced this bug when I tried to fix the last one, we'll see...

@kalekundert
Copy link
Contributor

I haven't gotten to this yet, but I haven't forgot about it. I'll try to keep you updated...

@dumbasaroc
Copy link
Author

That's alright! School starts for me in a few days, so I'll be a little bit busy too! But thank you!

@kalekundert
Copy link
Contributor

Ok, I finally got around to this today, but unfortunately I wasn't able to reproduce the behavior you described. Can you make a minimal working example that exhibits the bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants