KeyHelpTools add pin , and keep enable when hasModifierOn

This commit is contained in:
csf 2023-02-12 22:20:51 +09:00
parent 6e4e463f5f
commit 4b52431dbf

@ -85,7 +85,6 @@ class _RemotePageState extends State<RemotePage> {
} }
void onSoftKeyboardChanged(bool visible) { void onSoftKeyboardChanged(bool visible) {
inputModel.resetModifiers();
if (!visible) { if (!visible) {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
// [pi.version.isNotEmpty] -> check ready or not, avoid login without soft-keyboard // [pi.version.isNotEmpty] -> check ready or not, avoid login without soft-keyboard
@ -719,11 +718,12 @@ class KeyHelpTools extends StatefulWidget {
class _KeyHelpToolsState extends State<KeyHelpTools> { class _KeyHelpToolsState extends State<KeyHelpTools> {
var _more = true; var _more = true;
var _fn = false; var _fn = false;
var _pin = false;
InputModel get inputModel => gFFI.inputModel; InputModel get inputModel => gFFI.inputModel;
Widget wrap(String text, void Function() onPressed, Widget wrap(String text, void Function() onPressed,
[bool? active, IconData? icon]) { {bool? active, IconData? icon}) {
return TextButton( return TextButton(
style: TextButton.styleFrom( style: TextButton.styleFrom(
minimumSize: Size(0, 0), minimumSize: Size(0, 0),
@ -737,7 +737,7 @@ class _KeyHelpToolsState extends State<KeyHelpTools> {
backgroundColor: active == true ? MyTheme.accent80 : null, backgroundColor: active == true ? MyTheme.accent80 : null,
), ),
child: icon != null child: icon != null
? Icon(icon, size: 17, color: Colors.white) ? Icon(icon, size: 14, color: Colors.white)
: Text(translate(text), : Text(translate(text),
style: TextStyle(color: Colors.white, fontSize: 11)), style: TextStyle(color: Colors.white, fontSize: 11)),
onPressed: onPressed); onPressed: onPressed);
@ -745,8 +745,13 @@ class _KeyHelpToolsState extends State<KeyHelpTools> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (!widget.requestShow) { final hasModifierOn = inputModel.ctrl ||
return SizedBox(); inputModel.alt ||
inputModel.shift ||
inputModel.command;
if (!_pin && !hasModifierOn && !widget.requestShow) {
return Offstage();
} }
final size = MediaQuery.of(context).size; final size = MediaQuery.of(context).size;
@ -755,16 +760,16 @@ class _KeyHelpToolsState extends State<KeyHelpTools> {
final modifiers = <Widget>[ final modifiers = <Widget>[
wrap('Ctrl ', () { wrap('Ctrl ', () {
setState(() => inputModel.ctrl = !inputModel.ctrl); setState(() => inputModel.ctrl = !inputModel.ctrl);
}, inputModel.ctrl), }, active: inputModel.ctrl),
wrap(' Alt ', () { wrap(' Alt ', () {
setState(() => inputModel.alt = !inputModel.alt); setState(() => inputModel.alt = !inputModel.alt);
}, inputModel.alt), }, active: inputModel.alt),
wrap('Shift', () { wrap('Shift', () {
setState(() => inputModel.shift = !inputModel.shift); setState(() => inputModel.shift = !inputModel.shift);
}, inputModel.shift), }, active: inputModel.shift),
wrap(isMac ? ' Cmd ' : ' Win ', () { wrap(isMac ? ' Cmd ' : ' Win ', () {
setState(() => inputModel.command = !inputModel.command); setState(() => inputModel.command = !inputModel.command);
}, inputModel.command), }, active: inputModel.command),
]; ];
final keys = <Widget>[ final keys = <Widget>[
wrap( wrap(
@ -777,7 +782,14 @@ class _KeyHelpToolsState extends State<KeyHelpTools> {
} }
}, },
), ),
_fn), active: _fn),
wrap(
'',
() => setState(
() => _pin = !_pin,
),
active: _pin,
icon: Icons.push_pin),
wrap( wrap(
' ... ', ' ... ',
() => setState( () => setState(
@ -788,7 +800,7 @@ class _KeyHelpToolsState extends State<KeyHelpTools> {
} }
}, },
), ),
_more), active: _more),
]; ];
final fn = <Widget>[ final fn = <Widget>[
SizedBox(width: 9999), SizedBox(width: 9999),
@ -828,16 +840,16 @@ class _KeyHelpToolsState extends State<KeyHelpTools> {
SizedBox(width: 9999), SizedBox(width: 9999),
wrap('', () { wrap('', () {
inputModel.inputKey('VK_LEFT'); inputModel.inputKey('VK_LEFT');
}, false, Icons.keyboard_arrow_left), }, icon: Icons.keyboard_arrow_left),
wrap('', () { wrap('', () {
inputModel.inputKey('VK_UP'); inputModel.inputKey('VK_UP');
}, false, Icons.keyboard_arrow_up), }, icon: Icons.keyboard_arrow_up),
wrap('', () { wrap('', () {
inputModel.inputKey('VK_DOWN'); inputModel.inputKey('VK_DOWN');
}, false, Icons.keyboard_arrow_down), }, icon: Icons.keyboard_arrow_down),
wrap('', () { wrap('', () {
inputModel.inputKey('VK_RIGHT'); inputModel.inputKey('VK_RIGHT');
}, false, Icons.keyboard_arrow_right), }, icon: Icons.keyboard_arrow_right),
wrap(isMac ? 'Cmd+C' : 'Ctrl+C', () { wrap(isMac ? 'Cmd+C' : 'Ctrl+C', () {
sendPrompt(isMac, 'VK_C'); sendPrompt(isMac, 'VK_C');
}), }),