use hidden textfield to capture input

This commit is contained in:
open-trade 2020-11-22 18:29:04 +08:00
parent 25b2f52462
commit f6f7e1ead1
2 changed files with 132 additions and 118 deletions

View File

@ -138,8 +138,8 @@ class ImageModel with ChangeNotifier {
class CursorModel with ChangeNotifier { class CursorModel with ChangeNotifier {
ui.Image _image; ui.Image _image;
final _images = Map<int, ui.Image>(); final _images = Map<int, ui.Image>();
double _x = 0; double _x = -10000;
double _y = 0; double _y = -10000;
double _hotx = 0; double _hotx = 0;
double _hoty = 0; double _hoty = 0;
double _displayOriginX = 0; double _displayOriginX = 0;
@ -189,6 +189,8 @@ class CursorModel with ChangeNotifier {
} }
void clear() { void clear() {
_x = -10000;
_x = -10000;
_image = null; _image = null;
_images.clear(); _images.clear();
} }

View File

@ -85,10 +85,7 @@ class _RemotePageState extends State<RemotePage> {
// Size size = MediaQueryData.fromWindow(ui.window).size; // Size size = MediaQueryData.fromWindow(ui.window).size;
// MediaQuery.of(context).size.height; // MediaQuery.of(context).size.height;
EasyLoading.instance.loadingStyle = EasyLoadingStyle.light; EasyLoading.instance.loadingStyle = EasyLoadingStyle.light;
return RawKeyboardListener( return WillPopScope(
focusNode: _focusNode,
onKey: _handleKeyEvent,
child: WillPopScope(
onWillPop: () async { onWillPop: () async {
close(); close();
return false; return false;
@ -125,9 +122,9 @@ class _RemotePageState extends State<RemotePage> {
onPressed: () { onPressed: () {
SystemChrome.setEnabledSystemUIOverlays( SystemChrome.setEnabledSystemUIOverlays(
SystemUiOverlay.values); SystemUiOverlay.values);
_focusNode.requestFocus();
SystemChannels.textInput SystemChannels.textInput
.invokeMethod('TextInput.show'); .invokeMethod('TextInput.show');
_focusNode.requestFocus();
}), }),
Transform.rotate( Transform.rotate(
angle: 15 * math.pi / 180, angle: 15 * math.pi / 180,
@ -208,9 +205,24 @@ class _RemotePageState extends State<RemotePage> {
child: Stack(children: [ child: Stack(children: [
ImagePaint(), ImagePaint(),
CursorPaint(), CursorPaint(),
SizedBox(
width: 0,
height: 0,
child: _bottom < 100
? Container()
: TextFormField(
textInputAction: TextInputAction.newline,
autocorrect: false,
enableSuggestions: false,
focusNode: _focusNode,
maxLines: null,
keyboardType: TextInputType.multiline,
onChanged: (x) => print('$x'),
),
),
])), ])),
)), )),
))))); ))));
} }
void close() { void close() {