mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Not super pretty, but implements keyboard navigation for the adhoc server list
This commit is contained in:
@@ -1201,6 +1201,36 @@ bool ClickableTextView::Touch(const TouchInput &input) {
|
||||
return contains;
|
||||
}
|
||||
|
||||
bool ClickableTextView::Key(const KeyInput &key) {
|
||||
if (!HasFocus() && key.deviceId != DEVICE_ID_MOUSE) {
|
||||
down_ = false;
|
||||
return false;
|
||||
}
|
||||
// TODO: Replace most of Update with this.
|
||||
|
||||
bool ret = false;
|
||||
if (key.flags & KeyInputFlags::DOWN) {
|
||||
if (IsAcceptKey(key)) {
|
||||
down_ = true;
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
if (key.flags & KeyInputFlags::UP) {
|
||||
if (IsAcceptKey(key)) {
|
||||
if (down_) {
|
||||
EventParams e{};
|
||||
e.v = this;
|
||||
OnClick.Trigger(e);
|
||||
down_ = false;
|
||||
ret = true;
|
||||
}
|
||||
} else if (down_ && IsEscapeKey(key)) {
|
||||
down_ = false;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
TextEdit::TextEdit(std::string_view text, std::string_view title, std::string_view placeholderText, LayoutParams *layoutParams)
|
||||
: View(layoutParams), text_(text), title_(title), undo_(text), placeholderText_(placeholderText),
|
||||
textColor_(0xFFFFFFFF), maxLen_(255) {
|
||||
|
||||
@@ -1086,6 +1086,8 @@ public:
|
||||
ClickableTextView(std::string_view text, LayoutParams *layoutParams = 0)
|
||||
: TextView(text, layoutParams) {}
|
||||
bool Touch(const TouchInput &input) override;
|
||||
bool Key(const KeyInput &input) override;
|
||||
|
||||
Event OnClick;
|
||||
|
||||
private:
|
||||
|
||||
@@ -223,7 +223,13 @@ AdhocServerRow::AdhocServerRow(std::string *editValue, const AdhocServerListEntr
|
||||
|
||||
LinearLayout *lines = Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(Margins(5, 5))));
|
||||
lines->SetSpacing(0.0f);
|
||||
lines->Add(new TextView(entry.name));
|
||||
ClickableTextView *name = lines->Add(new ClickableTextView(entry.name));
|
||||
name->SetFocusable(true);
|
||||
name->OnClick.Add([this](UI::EventParams &e) {
|
||||
EventParams e2;
|
||||
e2.v = this;
|
||||
OnSelected.Trigger(e2);
|
||||
});
|
||||
|
||||
std::string secondLine = entry.host;
|
||||
if (entry.host == "localhost") {
|
||||
|
||||
Reference in New Issue
Block a user