navigate with enter

This commit is contained in:
Sander Land committed 2020-12-26 20:22:46 +01:00
1 parent 87e83055d6
commit 769623973a
3 files changed
+17 -3

No files matched your search

+4 -1
View File
@@ -696,6 +696,9 @@ class LoadSGFPopup(BoxLayout):
self.filesel.path = os.path.abspath(os.path.expanduser(app.gui.config("general/sgf_load"))) self.filesel.path = os.path.abspath(os.path.expanduser(app.gui.config("general/sgf_load")))
self.filesel.select_string = i18n._("Load File") self.filesel.select_string = i18n._("Load File")
def on_submit(self):
self.filesel.button_clicked()
class SaveSGFPopup(BoxLayout): class SaveSGFPopup(BoxLayout):
def __init__(self, suggested_filename, **kwargs): def __init__(self, suggested_filename, **kwargs):
@@ -716,7 +719,7 @@ class SaveSGFPopup(BoxLayout):
self.filesel.select_string = i18n._("Save File") self.filesel.select_string = i18n._("Save File")
def on_submit(self): def on_submit(self):
self.filesel.dispatch("on_success") self.filesel.button_clicked()
class ReAnalyzeGamePopup(BoxLayout): class ReAnalyzeGamePopup(BoxLayout):
+11 -2
View File
@@ -40,7 +40,7 @@ a shortcut to the Documents directory added to the favorites bar::
import string import string
from functools import partial from functools import partial
from os import walk from os import walk
from os.path import dirname, expanduser, getmtime, isdir, join, sep from os.path import dirname, expanduser, getmtime, isdir, isfile, join, sep
from kivy import Config from kivy import Config
from kivy.clock import Clock from kivy.clock import Clock
@@ -172,6 +172,7 @@ Builder.load_string(
spacing: 5 spacing: 5
padding: [6, 6, 6, 6] padding: [6, 6, 6, 6]
select_state: select_button.state select_state: select_button.state
file_text: file_text
filename: file_text.text filename: file_text.text
browser: list_view browser: list_view
on_favorites: link_tree.reload_favs(self.favorites) on_favorites: link_tree.reload_favs(self.favorites)
@@ -232,7 +233,7 @@ Builder.load_string(
height: '40dp' height: '40dp'
size_hint_x: None size_hint_x: None
text: root.select_string text: root.select_string
on_release: root.dispatch('on_success') on_release: root.button_clicked()
""" """
) )
@@ -319,6 +320,8 @@ class I18NFileBrowser(BoxLayout):
__events__ = ("on_success", "on_submit") __events__ = ("on_success", "on_submit")
file_must_exist = BooleanProperty(False) # whether new file paths can be pointed at
select_state = OptionProperty("normal", options=("normal", "down")) select_state = OptionProperty("normal", options=("normal", "down"))
"""State of the 'select' button, must be one of 'normal' or 'down'. """State of the 'select' button, must be one of 'normal' or 'down'.
The state is 'down' only when the button is currently touched/clicked, The state is 'down' only when the button is currently touched/clicked,
@@ -464,3 +467,9 @@ class I18NFileBrowser(BoxLayout):
def _attr_callback(self, attr, obj, value): def _attr_callback(self, attr, obj, value):
setattr(self, attr, getattr(obj, attr)) setattr(self, attr, getattr(obj, attr))
def button_clicked(self):
if isdir(self.file_text.text):
self.path = self.file_text.text
elif not self.file_must_exist or isfile(self.file_text.text):
self.dispatch("on_success")
+2
View File
@@ -608,6 +608,7 @@
I18NFileBrowser: I18NFileBrowser:
id: filesel id: filesel
multiselect: False multiselect: False
file_must_exist: True
filters: ["*.sgf","*.gib","*.ngf"] filters: ["*.sgf","*.gib","*.ngf"]
path: "." path: "."
size_hint: 1,7 size_hint: 1,7
@@ -618,6 +619,7 @@
I18NFileBrowser: I18NFileBrowser:
id: filesel id: filesel
multiselect: False multiselect: False
file_must_exist: False
filters: ["*.sgf","*.gib","*.ngf"] filters: ["*.sgf","*.gib","*.ngf"]
path: "." path: "."
size_hint: 1,7 size_hint: 1,7