B4J Question Clear clipboard

prokli

Active Member
Licensed User
Longtime User
Hello!

Does someone know, how to clear the clipboard in B4J?

I use "fx.Clipboard.HasImage" within a timer function to check if there is an Image stored to clipboard.
If so, I read the image to a variable, like this: "clipImage = fx.Clipboard.GetImage"
Problem: after I have copied an Image to clipboard, the variable "fx.Clipboard.HasImage" remains TRUE.
So how can I reset this variable or how can I clear the clipboard content???

Thx, Harald
 

Daestrum

Expert
Licensed User
Longtime User
A bit hackish but
B4X:
    Dim myClipBoard As JavaObject
    myClipBoard.InitializeStatic("javafx.scene.input.Clipboard")
    myClipBoard.RunMethodJO("getSystemClipboard",Null).RunMethod("clear",Null)
should work.

Once defined you can just run the last line whenever you need it cleared.
 
Last edited:
Upvote 0
Top