Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Textbox SelLength Assign problem
Message
 
To
30/04/2002 09:45:09
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00650820
Message ID:
00650850
Views:
22
>Hi All,
>
> anyone have a solution to this problem? We're trying to put Basic Copy/Paste functionality into a bespoke command group to mimic the Ctrl C / Ctrl X / Ctrl V functions of the FoxPro memu. If a user selects a piece of text in a textbox, either with the mouse or Shift Arrow or Ctrl A, we need to be able to avtivate or deactivate the Copy button based on whether a piece of text is selected or not in the current textbox.
>
> The trouble is, we can't seem to find an event to do this in. We first tried putting in an assign method on the SelLength property, but this isn't fired is it's the user who changes the length of the selected text. I thought of trapping Key presses and mouse events (MouseUp?), and even using a timer à la Ken Levy, but it seems a bit heavy going, especially since this is going to go into a base textbox class for the project.
>
> We can't use the When event, since we want this to work as soon as the user selects some text, just as the FoxPro toolbar works is interactive mode. Anyone have any ideas?
>
>Best wishes,
>Neil
Neil,

In my menu I do a Skip for then one of the following functions SkipCut(), SkipCopy(), SkipPaste() SkipReadOnly().

These are then something like:
Function SkipCopy
local loForm, loControl
	*-- Check for an active form.
	if type("_screen.ActiveForm")="O"
		loForm = _screen.ActiveForm
		*-- Check for an active control.
		if type("loForm.ActiveControl")="O"
			loControl = loForm.ActiveControl
			*-- If part of the control is selected then the Copy can go ahead.
			return iif(loControl.SelLength=0, .T., .F.)
		endif
	endif
return .T.

Function SkipPaste
local loForm, loControl
	*-- Check for an active form.
	if type("_screen.ActiveForm")="O"
		loForm = _screen.ActiveForm
		*-- Check for an active control.
		if type("loForm.ActiveControl")="O"
			loControl = loForm.ActiveControl
			*-- If the object is not ReadOnly and the _ClipText is not empty then the Paste can go ahead.
			return iif(loControl.ReadOnly or empty (_ClipText), .T., .F.)
		endif
	endif
return .T.
HTH
Caroline
Previous
Reply
Map
View

Click here to load this message in the networking platform