Skip to content

Commit 36968dd

Browse files
authored
Fix back-key handling (#107)
1 parent 52d2836 commit 36968dd

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

flutter/shell/platform/tizen/flutter_tizen_view.cc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,21 @@ void FlutterTizenView::OnKey(const char* key,
336336
}
337337

338338
if (engine_->keyboard_channel()) {
339+
bool& backkey_handled = backkey_handled_;
339340
engine_->keyboard_channel()->SendKey(
340341
key, string, compose, modifiers, scan_code, is_down,
341-
[engine = engine_.get(), symbol = std::string(key),
342-
is_down](bool handled) {
342+
[engine = engine_.get(), symbol = std::string(key), is_down,
343+
&backkey_handled](bool handled) {
344+
// If System's back key is handled in key-down, it should be
345+
// handled so that "popRoute" is not called in key-up.
346+
if (symbol == kBackKey) {
347+
if (is_down) {
348+
backkey_handled = handled;
349+
} else {
350+
handled |= backkey_handled;
351+
backkey_handled = false;
352+
}
353+
}
343354
if (handled) {
344355
return;
345356
}

flutter/shell/platform/tizen/flutter_tizen_view.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ class FlutterTizenView : public TizenViewEventHandlerDelegate {
213213
0.0, 0.0, 0.0, 1.0};
214214
// The user-defined pixel ratio.
215215
double user_pixel_ratio_ = 0;
216+
217+
// Whether the back key of the system has been handled.
218+
bool backkey_handled_ = false;
216219
};
217220

218221
} // namespace flutter

0 commit comments

Comments
 (0)