Pasting Text

TedN

Member
Licensed User
Longtime User
What is the best way for a user to paste a large amount of text into say a label.
I've tried using an EditText with the idea of making the label.text = editText.text. However, the emulator doesn't accept Ctl + V for pasting.
And I get a message coming up asking what type of input is required.

It would be nice if text could be pasted directly into an editText or some other view by a user which was then accessible programatically.

Thanks
 

TedN

Member
Licensed User
Longtime User
Thanks Erel. That kinda works. If I type some text into the the EditText I can cut and paste that text.

However, if I go to a text source outside of the program, say this forum site, and copy some text, it won't allow me to paste that text into the EditText. The original EditText gets pasted again instead.

What I would like top do is copy text from say a Word document and paste that into the EditText while the program is running. The text in the EditText would then be programmatically transfered to a label.

Also, when the keyboard pops up in the emulator, how do you get rid of it. Is there a tutorial on using the emulator.

Thanks,
 
Upvote 0

TedN

Member
Licensed User
Longtime User
Moster,
Thanks for the tip.
Could someone give me an example of the use of BClipboard.

I've tried:

str = Acitivity.getText()
str = Acitivity.getText(BClipboard)
str = Acitivity.BClipboard.getText()
Etc, etc.
I've loaded the Clipboard file in the library and checked it in Libs.

Thanks,
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You need to Dim an object first, So :

B4X:
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.

   Dim Clip As BClipboard

End Sub

Sub Activity_Create(FirstTime As Boolean)
   Clip.setText("TestClip")
   If Clip.hasText Then 
      Log(Clip.getText)
   Else 
      Log("Nothing to paste")
   End If
      

End Sub

Steve
 
Upvote 0

TedN

Member
Licensed User
Longtime User
Steve,
Thanks for your reply.

I can get BClip to work now using clip.setText("Some text").

But it still doesn't work if I put text in my clipboard (computer clipboard).

Do I need to point BClip to my pc clipboard somehow.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Sorry, I didn't, read the whole thread. It is unlikely that you will be able to access the PC's clipboard from Android.

If it works like the command prompt, it may respond to Ctrl v in the emulator, but that will be all PC side.

Steve

Sent from my Hero using Tapatalk
 
Upvote 0

TedN

Member
Licensed User
Longtime User
That's too bad. It's a bit of a show stopper for my app.

In VB.Net one could use: Me.Text = My.Computer.Clipboard.GetText

I guess there aren't the "hooks" in B4A to make use of that for getting text from the PC clipboard.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
The Android emulator is just that
, and provides a separate environment running under windows so there are not really any 'hooks' to be had.

If you are familiar with Java, you could try using the Robot class to pass data from the PC's clipboard to the keyboard buffer (or any other language you are familiar with that supports writing to the keyboard buffer.

Just a thought

Steve

Sent from my Hero using Tapatalk
 
Upvote 0
Top