Cut and Paste

Blitz3D Forums/Blitz3D Beginners Area/Cut and Paste

Fry Crayola(Posted 2004) [#1]
I'm creating a data editor at the moment, which is doing quite well. I've managed to get some edit boxes working - when clicked upon, you get a cursor and can edit the text within.

There are a few problems though. The main one is that I can't do cut and paste - not normally a problem but I'll be looking at including accents and language-specific characters using the Character Map. Without actually programming in a character map of my own, I don't see a way to do this.

Here's the code

Function editbox(clicked)
	edits(clicked)\enteredText = edits(clicked)\enteredText + "|"
	FlushKeys
	Repeat
		If edits(clicked)\textSize = 1
			SetFont largefont
		Else
			SetFont smallfont
		EndIf
	
		If edits(clicked)\limitType = Pixels Then
			If StringWidth(edits(clicked)\enteredText) >= edits(clicked)\limit
				limit = True
			Else
				limit = False
			End If
		Else
			If Len(edits(clicked)\enteredText) > edits(clicked)\limit
				limit = True
			Else
				limit = False
			End If
		End If
		
		a = GetKey()
		If a>=32 And a<127 And (Not limit)
			edits(clicked)\enteredText = Left$(edits(clicked)\enteredText, Len(edits(clicked)\enteredText)-1) + Chr$(a) + "|"
		End If
		If KeyHit(14) And Len(edits(clicked)\enteredText)>1
			edits(clicked)\enteredText = Left$(edits(clicked)\enteredText, Len(edits(clicked)\enteredText)-2) + "|"
		End If
	updatescreen()
	Until KeyHit(28)
	edits(clicked)\enteredText = Left$(edits(clicked)\enteredText, Len(edits(clicked)\enteredText)-1)
End Function



Perturbatio(Posted 2004) [#2]
you could use SetClipBoardData and GetClipBoardData from the winAPI.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/DataExchange/Clipboard/ClipboardReference/ClipboardFunctions/SetClipboardData.asp


gpete(Posted 2004) [#3]
Fry,

Blitz supports the use of Ctrl-KC for cut and Ctrl-KV for paste, these are "old" Wordstar commands that are still useful. For example, when looking at the Blitz help file, you can use these to cut and paste from the command references. Perhaps you can assign these characters to the mousehit event.