Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Gurgen Hovhannisyan authored and Gurgen Hovhannisyan committed Apr 2, 2019
1 parent 3ed592b commit 5fdc143
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 31 deletions.
62 changes: 32 additions & 30 deletions lib/src/keyboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,29 +219,32 @@ class _VirtualKeyboardState extends State<VirtualKeyboard> {
switch (key.action) {
case VirtualKeyboardKeyAction.Backspace:
actionKey = GestureDetector(
onLongPress: () {
longPress = true;
// Start sending backspace key events while longPress is true
Timer.periodic(
Duration(milliseconds: _virtualKeyboardBackspaceEventPerioud),
(timer) {
if (longPress) {
onKeyPress(key);
} else {
// Cancel timer.
timer.cancel();
}
});
},
onLongPressUp: () {
// Cancel event loop
longPress = false;
},
child: Icon(
Icons.backspace,
color: textColor,
),
);
onLongPress: () {
longPress = true;
// Start sending backspace key events while longPress is true
Timer.periodic(
Duration(milliseconds: _virtualKeyboardBackspaceEventPerioud),
(timer) {
if (longPress) {
onKeyPress(key);
} else {
// Cancel timer.
timer.cancel();
}
});
},
onLongPressUp: () {
// Cancel event loop
longPress = false;
},
child: Container(
height: double.infinity,
width: double.infinity,
child: Icon(
Icons.backspace,
color: textColor,
),
));
break;
case VirtualKeyboardKeyAction.Shift:
actionKey = Icon(Icons.arrow_upward, color: textColor);
Expand All @@ -260,21 +263,20 @@ class _VirtualKeyboardState extends State<VirtualKeyboard> {
return Expanded(
child: InkWell(
onTap: () {
if (!alwaysCaps) {
if (key.action == VirtualKeyboardKeyAction.Shift) {
if (key.action == VirtualKeyboardKeyAction.Shift) {
if (!alwaysCaps) {
setState(() {
isShiftEnabled = !isShiftEnabled;
});
}

onKeyPress(key);
}

onKeyPress(key);
},
child: Container(
alignment: Alignment.center,
height: height / _keyRows.length,
child: Center(
child: actionKey,
),
child: actionKey,
),
),
);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: virtual_keyboard
description: A simple package for dispaying virtual keyboards on a devices like kiosks and ATMs. The library is written in Dart and has no native code dependancy.
version: 0.1.3
version: 0.1.4
author: Gurgen Hovhannisyan <g.hovhannisyan@digitalpomegranate.com>
homepage: https://github.com/gurgenDP/virtual_keyboard

Expand Down

0 comments on commit 5fdc143

Please sign in to comment.