mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
SC2 Client: Fix missing mission tooltip after KivyMD switch (#4827)
This commit is contained in:
@@ -5,12 +5,11 @@ from NetUtils import JSONMessagePart
|
|||||||
from kvui import GameManager, HoverBehavior, ServerToolTip, KivyJSONtoTextParser
|
from kvui import GameManager, HoverBehavior, ServerToolTip, KivyJSONtoTextParser
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
from kivymd.uix.tab import MDTabsItem, MDTabsItemText
|
|
||||||
from kivy.uix.gridlayout import GridLayout
|
from kivy.uix.gridlayout import GridLayout
|
||||||
from kivy.lang import Builder
|
from kivy.lang import Builder
|
||||||
from kivy.uix.label import Label
|
from kivy.uix.label import Label
|
||||||
from kivy.uix.button import Button
|
from kivy.uix.button import Button
|
||||||
from kivy.uix.floatlayout import FloatLayout
|
from kivymd.uix.tooltip import MDTooltip
|
||||||
from kivy.uix.scrollview import ScrollView
|
from kivy.uix.scrollview import ScrollView
|
||||||
from kivy.properties import StringProperty
|
from kivy.properties import StringProperty
|
||||||
|
|
||||||
@@ -26,30 +25,22 @@ class HoverableButton(HoverBehavior, Button):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class MissionButton(HoverableButton):
|
class MissionButton(HoverableButton, MDTooltip):
|
||||||
tooltip_text = StringProperty("Test")
|
tooltip_text = StringProperty("Test")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(HoverableButton, self).__init__(*args, **kwargs)
|
super(HoverableButton, self).__init__(**kwargs)
|
||||||
self.layout = FloatLayout()
|
self._tooltip = ServerToolTip(text=self.text, markup=True)
|
||||||
self.popuplabel = ServerToolTip(text=self.text, markup=True)
|
self._tooltip.padding = [5, 2, 5, 2]
|
||||||
self.popuplabel.padding = [5, 2, 5, 2]
|
|
||||||
self.layout.add_widget(self.popuplabel)
|
|
||||||
|
|
||||||
def on_enter(self):
|
def on_enter(self):
|
||||||
self.popuplabel.text = self.tooltip_text
|
self._tooltip.text = self.tooltip_text
|
||||||
|
|
||||||
if self.ctx.current_tooltip:
|
if self.tooltip_text != "":
|
||||||
App.get_running_app().root.remove_widget(self.ctx.current_tooltip)
|
self.display_tooltip()
|
||||||
|
|
||||||
if self.tooltip_text == "":
|
|
||||||
self.ctx.current_tooltip = None
|
|
||||||
else:
|
|
||||||
App.get_running_app().root.add_widget(self.layout)
|
|
||||||
self.ctx.current_tooltip = self.layout
|
|
||||||
|
|
||||||
def on_leave(self):
|
def on_leave(self):
|
||||||
self.ctx.ui.clear_tooltip()
|
self.remove_tooltip()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ctx(self) -> SC2Context:
|
def ctx(self) -> SC2Context:
|
||||||
|
Reference in New Issue
Block a user