~iamsylvie/ubuntu-keyboard/ubuntu-keyboard

« back to all changes in this revision

Viewing changes to plugins/ja/qml/keys/CursorKey.qml

  • Committer: CI Train Bot
  • Author(s): Mitsuya Shibata
  • Date: 2016-02-22 11:04:18 UTC
  • mfrom: (402.2.16 japanese-keyboard-rebooted)
  • Revision ID: ci-train-bot@canonical.com-20160222110418-1hn0utyw7pj0gsqf
Implement Japanese keyboard layout Fixes: #1290031
Approved by: Ken VanDine

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2015 Canonical Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU Lesser General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
import QtQuick 2.4
 
18
import "key_constants.js" as UI
 
19
import keys 1.0
 
20
 
 
21
ActionKey {
 
22
    label: action == "left" ? "⬅" : "➡";
 
23
    leftSide: action == "left";
 
24
    rightSide: action == "right";
 
25
 
 
26
    property string preedit: maliit_input_method.preedit
 
27
    property int cursorPosition: maliit_input_method.cursorPosition
 
28
    property bool isPreedit: preedit != ""
 
29
 
 
30
    overridePressArea: true;
 
31
 
 
32
    onReleased: {
 
33
        if (isPreedit) {
 
34
            if (action == "left" && cursorPosition > 0) {
 
35
                maliit_input_method.cursorPosition--
 
36
            } else if (action == "right" && cursorPosition < preedit.length) {
 
37
                maliit_input_method.cursorPosition++
 
38
            }
 
39
        } else {
 
40
            event_handler.onKeyReleased("", action);
 
41
        }
 
42
    }
 
43
 
 
44
    onPressed: {
 
45
        if (maliit_input_method.useAudioFeedback)
 
46
            audioFeedback.play();
 
47
 
 
48
        if (maliit_input_method.useHapticFeedback)
 
49
            pressEffect.start();
 
50
 
 
51
        if (!isPreedit)
 
52
            event_handler.onKeyPressed("", action);
 
53
    }
 
54
 
 
55
    onPressAndHold: {
 
56
        return;
 
57
    }
 
58
}