summaryrefslogtreecommitdiff
path: root/src/ui/inputwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-03-06 14:44:17 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-03-06 14:44:17 +0200
commiteddc86b7b0795fe7c7a82d86f6ee151ccdca229f (patch)
tree7eea8ac70aa37d068adfc2d06dc066367a10572c /src/ui/inputwidget.c
parent7fa64b95d0c63b243f50b23c5551a7e04fe90c30 (diff)
Mobile: Dealing with keyboard height
The software keyboard obstructs part of the UI, so need to offset the view if the focused input widget would not be visible.
Diffstat (limited to 'src/ui/inputwidget.c')
-rw-r--r--src/ui/inputwidget.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 3f178fc5..06bb9474 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -21,6 +21,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 21SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
22 22
23#include "inputwidget.h" 23#include "inputwidget.h"
24#include "command.h"
24#include "paint.h" 25#include "paint.h"
25#include "util.h" 26#include "util.h"
26#include "keys.h" 27#include "keys.h"
@@ -615,6 +616,17 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
615 } 616 }
616 return iFalse; 617 return iFalse;
617 } 618 }
619 else if (isCommand_UserEvent(ev, "keyboard.changed")) {
620 if (isFocused_Widget(d) && arg_Command(command_UserEvent(ev))) {
621 iRect rect = bounds_Widget(w);
622 rect.pos.y -= value_Anim(&get_Window()->rootOffset);
623 const iInt2 visRoot = visibleRootSize_Window(get_Window());
624 if (bottom_Rect(rect) > visRoot.y) {
625 setValue_Anim(&get_Window()->rootOffset, -(bottom_Rect(rect) - visRoot.y), 250);
626 }
627 }
628 return iFalse;
629 }
618 else if (isMetricsChange_UserEvent(ev)) { 630 else if (isMetricsChange_UserEvent(ev)) {
619 updateMetrics_InputWidget_(d); 631 updateMetrics_InputWidget_(d);
620 } 632 }