Sign up on the Revelation Software website to have access to the most current content, and to be able to ask questions and get answers from the Revelation community

At 14 DEC 1998 10:14:31PM Leslie wrote:

Sorry I have been away.

As Oystein said, I would like the user to be able to select several words from a box.

Eg:

 The quick brown fox jumped over the lazy dog.

I want the facility to be able to highlight 'brown fox' and 'dog' as keywords.

I can not see how more than 1 highlight can be done.


At 14 DEC 1998 10:50PM Don Bakke wrote:

Leslie,

I don't know how you can "highlight" multiple words the way you suggest either. It may be possible, but I've never seen it. However, perhaps an alternative to highlighting might work for you. Using the RTF control you could change the color of the font instead (or any other font based formatting like bold, underline, etc.)

dbakke@srpcs.com

SRP Computer Solutions


At 15 DEC 1998 09:19AM Oystein Reigem wrote:

Leslie,

I guess at this point somebody like Cameron or Carl or Gene would have told us if it really was possible to highlight more than one section of an edit line/box. Here are some alternative suggestions for you. All need some programming to realize:

- RTF edit box. You will not be able to select text the normal way. You need a fair amount of programming. Your mouse event handlers will know at which *pixel* the event happened, and then they will have to calculate which line and letter or word that was. I might help you with this. Also the highlighting will look different, because you cannot set text background colour. You may set the colour of the characters themselves, and the font, the size, etc. Furthermore your text must be pure 7-bit (until I get time to decode the source, which might never happen).

- Use a a normal edit box, and when the user selects something you have a handler that puts special markers on the selected words/phrases, like "The quick brown fox jumped over the lazy dog".

- Have a different control in addition to the edit box, something list-like like a list box or one-column edit table. When the user selects a word or phrase in the edit box you have a handler that copies the selected word/phrase to that second control.

- Oystein -


At 17 DEC 1998 12:51AM Leslie wrote:

Oystein,

Thanks for your suggestions.

But how do I design a handler to pick up the selected words?

The SELECTION will only handle one phrase. The DOUBLE CLICK event does not function as the Editor takes over.

Thanks for your interest


At 17 DEC 1998 06:38AM Oystein Reigem wrote:

Leslie,

Are you asking about plain edit box or the RTF edit box? I assume it's not RTF.

And is the text read-only? Or can the user also change the text inbetween selecting? I assume it's read only.

And just for now I'll also assume you can use my suggestion with the selected words and phrases being collected in a different control - e.g, a list box. Each time you select a word/phrase it will be added to the bottom of the list.

And I'll assume you always want to select whole words - never parts of words.

You are right about DBLCLK not working. I forgot that. You have to use WINMSG to get the edit box to react to mouse events. More about that in a minute. (Btw - If the edit box is bound to a symbolic field, the edit box will be disabled, and you cannot do anything - neither click nor scroll. But there is a simple solution to that too.)

In the meantime - how was it you (the user) wanted to operate the edit box again? Single words you want to double-click, right? Then it will be time-saving not to have to press e.g a special "Add" button to add the word to the list. The double-click should be enough. But what about phrases? E.g in MS Word you can highlight a phrase by double-clicking the first word, and then shift-click the last word. That is a neat feature, and you could program it such as to have the shift-click add the phrase to the list automatically. No need for a special "Add" button there either. But this phrase selection stuff will not work straight out of the box. The first reason is that the first word will be selected and added to the list already at the double-click. So you would have to remove the last item in the list if the user does a shift-click after a double-click. The second reason is that the shift-click sometimes does not select what it ought to, and not always whole words. Just try yours

elf to select backwords (click or double-click on the last word and then shift-click on the first word). Selecting forwards seems to work like in MS Word some of the time. Some extra programming to e.g extend the selection to cover whole words might perhaps solve the problem.

Enough talk. Make a window with no table. Make an edit box EB with some text and tick Read Only. Make a list box L and untick Sorted. Also make a list box M and untick Sorted. You will use M to monitor mouse messages so you better understand what goes on.

Make the following window CREATE handler:

<code>

    declare function Send_Message
    
    equ WM_LBUTTONDOWN   to 513   /* 513=$0201=left button down */
    equ WM_LBUTTONUP     to 514   /* 514=$0202=left button up */
    equ WM_LBUTTONDBLCLK to 515   /* 515=$0203=left double-click */
    
    unUsed=Send_Message( @Window : ".EB", "QUALIFY_EVENT", WM_LBUTTONDOWN,   1 )
    unUsed=Send_Message( @Window : ".EB", "QUALIFY_EVENT", WM_LBUTTONUP,     1 )
    unUsed=Send_Message( @Window : ".EB", "QUALIFY_EVENT", WM_LBUTTONDBLCLK, 1 )

RETURN 0

</code>

This handler will make the edit box EB able react to three mouse events - "left mouse button down", "left mouse button up", and "left mouse button down which is the second down in a double-click". Such messages, and others too, will always be generated when the user operates the mouse, but with this handler you make edit box aware of them.

If the user clicks once in the edit box, these messages will be generated as far as the edit box knows:

<code>

WM_LBUTTONDOWN
WM_LBUTTONUP

</code>

If the user double-clicks in the edit box, these messages will be generated:

<code>

WM_LBUTTONDOWN
WM_LBUTTONUP
WM_LBUTTONDBLCLK
WM_LBUTTONUP

</code>

If the user presses the mouse button down while in the edit box, but drags the cursor outside the box before he releases it, the edit box will only know of a

<code>

WM_LBUTTONDOWN

</code>

message. Etc.

Now make the following WINMSG handler for the edit box:

<code>

    equ WM_LBUTTONDOWN to 513     /* 513=$0201=left button down */
    equ WM_LBUTTONUP   to 514     /* 514=$0202=left button up */
    equ WM_LBUTTONDBLCLK to 515   /* 515=$0203=left double-click */
    
    declare function Send_Message
    
    /* monitor messages */
    InsertedPosition=Send_Message( @Window : ".M", "INSERT", -1, Message : " " : wParam )
    
    /* we use the user-defined property @STATE to know if the last click was single or double: */
    State=Get_Property( CtrlEntId, "@STATE" )
    
    if (Message=WM_LBUTTONDBLCLK) or ((Message=WM_LBUTTONUP) and (wParam=4)) then
    
        /* this was either the second down of a double-click, or the up of a shift-click.
           (wParam seems to be 4 for shift-up, 5 for shift-down, 8 for ctrl-up, 9 for ctrl-down, etc) */
        
        Text=Get_Property( CtrlEntId, "TEXT" )
        Selection=Get_Property( CtrlEntId, "SELECTION" )
        SelectedText=TextSelection, Selection
        
        /* here might be some code for "cleaning up" the selection
           (whole words, etc) */
        
        if (State=D") and (Message=WM_LBUTTONUP) and (wParam=4) then
            /* this is a shift-click after a double-click.
               remove the last word of the list,
               because the user wants the whole phrase */
            RowIndex=Get_Property( @Window : ".L", "LIMIT" )
            InsertedPosition=Send_Message( @Window : ".L", "DELETE", RowIndex, SelectedText )
        end
        /* insert the selected word or phrase at the end of the list */
        DeletedItem=Send_Message( @Window : ".L", "INSERT", -1, SelectedText )
        
    end

    /* remember if last mouse down event was a double-click or a single click */
    begin case
    case Message=WM_LBUTTONDBLCLK
        Void=Get_Property( CtrlEntId, "@STATE", "D" )
    case Message=WM_LBUTTONDOWN
        Void=Get_Property( CtrlEntId, "@STATE", "" )
    /* else keep state */
    end case
    
RETURN 0

</code>

Now test run and see.

In addition to what I said about shift-clicking not always selecting what you expect or need, this demo of mine has no "undo" - no facility for removing words/phrases from the list.

- Oystein -


At 18 DEC 1998 12:25AM Leslie wrote:

Dear Oystein

A very grateful thanks for the program. It worked a treat. It will also of great advantage in otherareas as well.

A very Happy Christmas to you from all the Team here.

Leslie

View this thread on the forum...

  • third_party_content/community/commentary/forums_nonworks/45eb5cd4909726d1852566db0011cf06.txt
  • Last modified: 2024/01/04 21:00
  • by 127.0.0.1