Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Aug 20, 2018 5:45 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Mac clipboard & program timing problem
PostPosted: Tue Apr 02, 2013 2:43 am 
Offline

Joined: Sat Mar 30, 2013 6:02 am
Posts: 4
Hi,
I’m looking to capture the clipboard when cmd + c keystrokes are pressed and then to append some text in the clipboard.

Cmd + c on the string: “Hello”
Cmd + v result: “Hello –> added text”

This is my code, but I cannot make it work. I think it may be something to do with the copy in clipboard on Mac timing and my program.

// Global variables: cmdDown & cDown
// Controls: TextField1 & Timer1
// Timer1 period: 10
// ----------------------------------

// Code in Timer:

// Test for the cmd down
if Keyboard.AsyncCommandKey And cmdDown = False Then
cmdDown = True
ElseIf Keyboard.AsyncCommandKey = False And cmdDown = True Then
cmdDown = False
end if

// Test for the cmd + c key down
if Keyboard.AsyncKeyDown(08) And cDown = False And cmdDown = True Then
//TextField1.AppendText( "cmd + c key down" + EndOfLine)
cDown = True

// --> I guess I need a way to test here if the Mac Copy in Clipboard is finished before replacing it with the following:

// Get the clipboard
Dim clipboard As New Clipboard
If clipboard.TextAvailable Then
TextField1.AppendText( "BEFORE: " + clipboard.Text + EndOfLine)
clipboard.SetText(clipboard.Text + " --> added some text")
TextField1.AppendText( "AFTER: " + clipboard.Text + EndOfLine)
End if
clipboard.Close

ElseIf Keyboard.AsyncKeyDown(08) = False And cDown = True Then
cDown = False
end if


Thanks,
Nicolas


Top
 Profile  
Reply with quote  
 Post subject: Re: Mac clipboard & program timing problem
PostPosted: Tue Apr 02, 2013 8:14 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
WHERE is that code?
If it is not called from the KEYDOWN event of the controls involved, it is probably the problem.

And under most circumstances you don't need to mess with clipboard. All RealStudio controls that deal with text automatically interface with the clipboard .... as long as you LEAVE THE DEFAULT EDIT MENU alone. (you can hide it... you just cannot delete it)

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Mac clipboard & program timing problem
PostPosted: Tue Apr 02, 2013 11:28 am 
Offline

Joined: Sat Mar 30, 2013 6:02 am
Posts: 4
OK, I guess I wasn't really clear of what I want to do.

I would like to alter the clipboard content when I perform a "cmd + c" on any Mac application to add some text.
So next time I "cmd + v" on Word for example, I will see my altered text.

https://dl.dropbox.com/u/22372781/TestClipboard.rbp

Thanks,
Nicolas


Top
 Profile  
Reply with quote  
 Post subject: Re: Mac clipboard & program timing problem
PostPosted: Tue Apr 02, 2013 11:45 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
Then you MUST delete the CUT/PASTE entries on the default menu...... otherwise they are intercepted and processed before you ever see them.

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Mac clipboard & program timing problem
PostPosted: Tue Apr 02, 2013 11:59 am 
Offline
User avatar

Joined: Mon Feb 05, 2007 5:21 pm
Posts: 600
Location: New York, NY
Subclass the TextField and add a menu handler for EditCopy that does what you want. You have to manage enabling/disabling Copy too, but this isn't difficult.

If code is in a Timer, it will never work right. Doing it the way I outlined above will work 100% of the time.

_________________
Kem Tekinay
MacTechnologies Consulting
http://www.mactechnologies.com/

Need to develop, test, and refine regular expressions? Try RegExRX.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group