1 #ifndef __DALI_VIRTUAL_KEYBOARD_H__
2 #define __DALI_VIRTUAL_KEYBOARD_H__
5 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/signals/dali-signal.h>
23 #include <dali/public-api/object/property-map.h>
24 #include <dali/public-api/math/rect.h>
27 #ifdef DALI_ADAPTOR_COMPILATION // full path doesn't exist until adaptor is installed so we have to use relative
28 // @todo Make dali-adaptor code folder structure mirror the folder structure installed to dali-env
29 #include "input-method.h"
31 #include <dali/public-api/adaptor-framework/input-method.h>
38 * @brief This namespace is provided for application developers to be able to show and hide the on-screen keyboard.
40 * Key events are sent to the actor in focus. Focus is set through the actor Public API.
42 namespace VirtualKeyboard
47 typedef Signal< void () > VoidSignalType;
48 typedef Signal< void ( bool ) > StatusSignalType;
49 typedef Signal< void ( int ) > KeyboardResizedSignalType;
50 typedef Signal< void ( int ) > LanguageChangedSignalType;
55 * @brief The direction of text.
64 * @brief The meaning of the return key.
81 * @brief Show the virtual keyboard.
83 DALI_IMPORT_API void Show();
86 * @brief Hide the virtual keyboard.
88 DALI_IMPORT_API void Hide();
91 * @brief Returns whether the virtual keyboard is visible or not.
92 * @return true if visible, false otherwise.
94 DALI_IMPORT_API bool IsVisible();
97 * @brief Set one or more of the Input Method Settings
98 * @param[in] settingsMap Map of Settings to be applied.
100 DALI_IMPORT_API void ApplySettings( const Property::Map& settingsMap );
103 * @brief Set the specific return key into the virtual keyboard.
104 * @param[in] type the kind of return key types.
106 DALI_IMPORT_API void SetReturnKeyType( const InputMethod::ActionButton type );
109 * @brief Retrieve the current return key type.
110 * @return the type of retun key.
112 DALI_IMPORT_API InputMethod::ActionButton GetReturnKeyType();
115 * @brief Enable/disable prediction (predictive text).
117 * By default prediction text is enabled.
118 * @param[in] enable true or false to enable or disable
119 * Prediction can not be changed while the keyboard is visible. It must be set in advance of showing keyboard.
121 DALI_IMPORT_API void EnablePrediction(const bool enable);
124 * @brief Returns whether prediction is enabled in the virtual keyboard
125 * @return true if predictive text enabled, false otherwise.
127 DALI_IMPORT_API bool IsPredictionEnabled();
130 * @brief Provides size and position of keyboard.
132 * Position is relative to whether keyboard is visible or not.
133 * If keyboard is not visible then position will be off the screen.
134 * If keyboard is not being shown when this method is called the keyboard is partially setup (IMFContext) to get
135 * the values then taken down. So ideally GetSizeAndPosition() should be called after Show().
136 * @return rect which is keyboard panel x, y, width, height
138 DALI_IMPORT_API Dali::Rect<int> GetSizeAndPosition();
141 * @brief Rotates the keyboard orientation to the given angle.
143 * A value of 0 indicates the portrait orientation.
144 * Other valid values are 90, 180, 270.
145 * @param angle the angle is in degrees.
147 DALI_IMPORT_API void RotateTo(int angle);
150 * @brief Returns text direction of the keyboard's current input language.
151 * @return The direction of the text.
153 DALI_IMPORT_API TextDirection GetTextDirection();
156 * @brief Connect to this signal to be notified when the virtual keyboard is shown or hidden.
158 * A callback of the following type may be connected:
160 * void YourCallbackName(bool keyboardShown);
162 * If the parameter keyboardShown is true, then the keyboard has just shown, if it is false, then it
163 * has just been hidden.
164 * @return The signal to connect to.
166 DALI_IMPORT_API StatusSignalType& StatusChangedSignal();
169 * @brief Connect to this signal to be notified when the virtual keyboard is resized.
171 * A callback of the following type may be connected:
173 * void YourCallbackName( int resolvedResize );
175 * The parameter sends the resolved resize defined by the IMF.
177 * User can get changed size by using GetSizeAndPosition() in the callback
178 * @return The signal to connect to.
180 DALI_IMPORT_API KeyboardResizedSignalType& ResizedSignal();
183 * @brief Connect to this signal to be notified when the virtual keyboard's language is changed.
185 * A callback of the following type may be connected:
187 * void YourCallbackName( int resolvedLanguage );
189 * The parameter sends the resolved language defined by the IMF.
191 * User can get the text direction of the language by calling GetTextDirection() in the callback.
192 * @return The signal to connect to.
194 DALI_IMPORT_API LanguageChangedSignalType& LanguageChangedSignal();
196 } // namespace VirtualKeyboard
200 #endif // __DALI_VIRTUAL_KEYBOARD_H__