[WASTE-list] How to find out the selected text is inside or outside the viewrect

Marco Piovanelli marco.piovanelli at pobox.com
Tue Apr 25 05:39:47 EDT 2006


On Tue, 25 Apr 2006 14:29:50 +0530,
Vinay Prabhu (vinayprabhu at tataelxsi.co.in) wrote:



>Is there any way to find out the text selection is inside

>or outside the viewrect.


If you want a yes/no answer, you need to decide what to do
if the selection is *partially* visible. For example, the
criterion employed by WESelView() to determine whether the
selection range is visible or not is by looking at the free
endpoint of the selection (the one that moves if you type
shift+left/right arrow). Something like this:

bool IsSelectionVisible(WEReference inWE)
{
SInt32 selStart, selEnd;
SInt32 freeEndpoint;
LongPt position;
LongRect viewRect;

WEGetSelection(&selStart, &selEnd, inWE);
freeEndpoint = (WEGetSelectionAnchor(inWE) == selStart) ?
selEnd : selStart;
WEGetPoint(freeEndpoint, kHilite, &position, 0, inWE);
WEGetViewRect(&viewRect, inWE);
return WELongPointInLongRect(&position, &viewRect);
}

Hope this helps,


-- marco

--
It's not the data universe only, it's human conversation.
They want to turn it into a one-way flow that they have entirely
monetized. I look at the collective human mind as a kind of
ecosystem. They want to clear cut it. They want to go into the
rainforest of human thought and mow the thing down.



More information about the WASTE-list mailing list