@ -61,7 +61,7 @@ local InputText = InputContainer:new{
for_measurement_only = nil , -- When the widget is a one-off used to compute text height
for_measurement_only = nil , -- When the widget is a one-off used to compute text height
do_select = false , -- to start text selection
do_select = false , -- to start text selection
selection_start_pos = nil , -- selection start position
selection_start_pos = nil , -- selection start position
is_keyboard_hidden = false , -- to be able to show the keyboard again when it was hidden (by VK itself)
is_keyboard_hidden = false , -- to be able to show the keyboard again when it was hidden
}
}
-- only use PhysicalKeyboard if the device does not have touch screen
-- only use PhysicalKeyboard if the device does not have touch screen
@ -73,19 +73,19 @@ if Device:isTouchDevice() or Device:hasDPad() then
TapTextBox = {
TapTextBox = {
GestureRange : new {
GestureRange : new {
ges = " tap " ,
ges = " tap " ,
range = self.dimen
range = function ( ) return self.dimen end
}
}
} ,
} ,
HoldTextBox = {
HoldTextBox = {
GestureRange : new {
GestureRange : new {
ges = " hold " ,
ges = " hold " ,
range = self.dimen
range = function ( ) return self.dimen end
}
}
} ,
} ,
SwipeTextBox = {
SwipeTextBox = {
GestureRange : new {
GestureRange : new {
ges = " swipe " ,
ges = " swipe " ,
range = self.dimen
range = function ( ) return self.dimen end
}
}
} ,
} ,
-- These are just to stop propagation of the event to
-- These are just to stop propagation of the event to
@ -166,18 +166,21 @@ if Device:isTouchDevice() or Device:hasDPad() then
return true
return true
end
end
end
end
local input_dialog
local clipboard_value = Device.input . getClipboardText ( )
input_dialog = require ( " ui/widget/inputdialog " ) : new {
local clipboard_dialog
title = _ ( " Clipboard " ) ,
clipboard_dialog = require ( " ui/widget/textviewer " ) : new {
title = ( clipboard_value == nil or clipboard_value == " " ) and _ ( " Clipboard (empty) " ) or _ ( " Clipboard " ) ,
text = clipboard_value ,
width = math.floor ( Screen : getWidth ( ) * 0.8 ) ,
height = math.floor ( Screen : getHeight ( ) * 0.4 ) ,
justified = false ,
stop_events_propagation = true ,
stop_events_propagation = true ,
input_hint = _ ( " empty " ) ,
buttons_table = {
input = Device.input . getClipboardText ( ) ,
buttons = {
{
{
{
{
text = _ ( " A ll" ) ,
text = _ ( " Copy a ll" ) ,
callback = function ( )
callback = function ( )
UIManager : close ( input _dialog)
UIManager : close ( clipboard _dialog)
Device.input . setClipboardText ( table.concat ( self.charlist ) )
Device.input . setClipboardText ( table.concat ( self.charlist ) )
UIManager : show ( Notification : new {
UIManager : show ( Notification : new {
text = _ ( " All text copied to clipboard. " ) ,
text = _ ( " All text copied to clipboard. " ) ,
@ -185,9 +188,9 @@ if Device:isTouchDevice() or Device:hasDPad() then
end ,
end ,
} ,
} ,
{
{
text = _ ( " L ine" ) ,
text = _ ( " Copy l ine" ) ,
callback = function ( )
callback = function ( )
UIManager : close ( input _dialog)
UIManager : close ( clipboard _dialog)
local txt = table.concat ( self.charlist , " " , self : getStringPos ( { " \n " , " \r " } , { " \n " , " \r " } ) )
local txt = table.concat ( self.charlist , " " , self : getStringPos ( { " \n " , " \r " } , { " \n " , " \r " } ) )
Device.input . setClipboardText ( txt )
Device.input . setClipboardText ( txt )
UIManager : show ( Notification : new {
UIManager : show ( Notification : new {
@ -196,9 +199,9 @@ if Device:isTouchDevice() or Device:hasDPad() then
end ,
end ,
} ,
} ,
{
{
text = _ ( " W ord" ) ,
text = _ ( " Copy w ord" ) ,
callback = function ( )
callback = function ( )
UIManager : close ( input _dialog)
UIManager : close ( clipboard _dialog)
local txt = table.concat ( self.charlist , " " , self : getStringPos ( { " \n " , " \r " , " " } , { " \n " , " \r " , " " } ) )
local txt = table.concat ( self.charlist , " " , self : getStringPos ( { " \n " , " \r " , " " } , { " \n " , " \r " , " " } ) )
Device.input . setClipboardText ( txt )
Device.input . setClipboardText ( txt )
UIManager : show ( Notification : new {
UIManager : show ( Notification : new {
@ -211,13 +214,13 @@ if Device:isTouchDevice() or Device:hasDPad() then
{
{
text = _ ( " Cancel " ) ,
text = _ ( " Cancel " ) ,
callback = function ( )
callback = function ( )
UIManager : close ( input _dialog)
UIManager : close ( clipboard _dialog)
end ,
end ,
} ,
} ,
{
{
text = _ ( " Select " ) ,
text = _ ( " Select " ) ,
callback = function ( )
callback = function ( )
UIManager : close ( input _dialog)
UIManager : close ( clipboard _dialog)
UIManager : show ( Notification : new {
UIManager : show ( Notification : new {
text = _ ( " Set cursor to start of selection, then hold. " ) ,
text = _ ( " Set cursor to start of selection, then hold. " ) ,
} )
} )
@ -226,21 +229,17 @@ if Device:isTouchDevice() or Device:hasDPad() then
} ,
} ,
{
{
text = _ ( " Paste " ) ,
text = _ ( " Paste " ) ,
is_enter_default = true ,
callback = function ( )
callback = function ( )
local paste_value = input_dialog : getInputText ( )
if clipboard_value ~= nil and clipboard_value ~= " " then
if paste_value ~= " " then
UIManager : close ( clipboard_dialog )
UIManager : close ( input_dialog )
self : addChars ( clipboard_value )
Device.input . setClipboardText ( paste_value )
self : addChars ( paste_value )
end
end
end ,
end ,
} ,
} ,
} ,
} ,
} ,
} ,
}
}
UIManager : show ( input_dialog )
UIManager : show ( clipboard_dialog )
input_dialog : onShowKeyboard ( true )
end
end
return true
return true
end
end
@ -574,19 +573,10 @@ function InputText:onShowKeyboard(ignore_first_hold_release)
return true
return true
end
end
function InputText : onHideKeyboard ( )
if not self.has_nav_bar then
UIManager : close ( self.keyboard )
Device : stopTextInput ( )
self.is_keyboard_hidden = true
end
return self.is_keyboard_hidden
end
function InputText : onCloseKeyboard ( )
function InputText : onCloseKeyboard ( )
UIManager : close ( self.keyboard )
UIManager : close ( self.keyboard )
Device : stopTextInput ( )
Device : stopTextInput ( )
self.is_keyboard_hidden = true
end
end
function InputText : onCloseWidget ( )
function InputText : onCloseWidget ( )