Keyboard

omoba

Active Member
Licensed User
Longtime User
HI,

Pls help.

I want to copy text from an Edittext. Once I do the long_click, the keyboard comes up -normal thing.

Well I dont want that. This is what I want when I do a long_click/press

I dont want the keyboard to show.

I want to copy text.

I dont want user to be able to edit text (I have tried INPUT_TYPE = NONE --but then no copy option).
 

omoba

Active Member
Licensed User
Longtime User
Ok. I am putting the text in a label and cant copy paste.

With edittext copy/paste popup is auto. But nothing when I long press label.

I know I am not doing something. Pls, show some code or point me somewhere

Thanks
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
You can use the label_longClick event subroutine, and there popup a inputList containing the actions you want the user to be able to perform.

B4X:
sub label_longclick
dim ls as list, rst as int
ls.initialize
ls.addall(array as string("COPY","CUT","PASTE"))
rst=inputList(ls,"Choose:",-1)
select rst
case 0
'copy
case 1
'cut
case 2
'paste
case -1
return
end select
end sub
 
Upvote 0

omoba

Active Member
Licensed User
Longtime User
No luck.

Pls look at attached file.
 

Attachments

  • sample.bal
    2.8 KB · Views: 139
Last edited:
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
I've looked at it. It's a designer's file, not the actual code. Anyway, the code I posted works. If you need help with your coding, you can always upload it here, 'file->export as zip', I am sure there are many member of this forum, willing to help.
 
Upvote 0

omoba

Active Member
Licensed User
Longtime User
Well the popup (COPY CUT PASTE) does come up.

I choose copy then I dont what to do.

Nothing is copying, nothing paste.

Pls how do you copy from a label using long click? I guess I am nothing thinking straight

Thanks

:sign0163:
 
Upvote 0

omoba

Active Member
Licensed User
Longtime User
When the app is opened, a text file is loaded to a edittext box.

The user can then copy any word from the text in the edittext box.

The user can then paste the copied word/s to another edittext box within the app.

I have this working fine

BUT I don’t want the droid keyboard to come up and I don’t want the user to have access to edit the loaded text.

It was suggested that I use a label box; which I tried but I don’t know how to make it work.

Thanks
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
so user has to have the ability to partially select words? cool. split words and place them in different labels. user clicks the label -> grab the word -> place it at the element you want.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Does this code do what you expect ?
B4X:
Sub Globals
    Dim EditText1, EditText2 As EditText
    Dim Obj1 As Reflector
    Dim IME1 As IME
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("main")

    Obj1.Target = EditText1 
    EditText1.Tag = "EditText1"
    Obj1.SetOnLongClickListener("EditText1_LongClick")
    IME1.Initialize("")
End Sub

Sub EditText1_LongClick(viewtag As Object) As Boolean
    IME1.HideKeyboard
    Return False
End Sub

Sub EditText1_TextChanged (Old As String, New As String)
    EditText1.Text = Old
End Sub
Needs the Reflection and IME libraies.

Best regards.
 

Attachments

  • TextCopyPaste.zip
    6.9 KB · Views: 170
Last edited:
Upvote 0
Top