Xojo Conferences
XDCMay2019MiamiUSA

Character background color in TextArea (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: Slow Load of Initial Menubar Click
Next thread: [WE] testing results for the Animator example


Re: RS2012r2?   -   Garth Hjelte
  Character background color in TextArea   -   Kem Tekinay
   Re: Character background color in TextArea   -   Karen
   Re: Character background color in TextArea   -   William Shank
   Re: Character background color in TextArea   -   Myron Meyer
   Re: Character background color in TextArea   -   Myron Meyer
   Re: Character background color in TextArea   -   Kem Tekinay
   Re: Character background color in TextArea   -   Myron Meyer

Character background color in TextArea
Date: 28.03.12 14:47 (Wed, 28 Mar 2012 09:47:12 -0400)
From: Kem Tekinay
Is there a way to create per-character background color in a TextArea? I want to simulate the effect of highlighting words or paragraphs on a page with a marker.

Re: Character background color in TextArea
Date: 01.04.12 19:56 (Sun, 01 Apr 2012 14:56:40 -0400)
From: Karen

On Apr 1, 2012, at 2:44 PM, William Shank wrote:

> On Wed, Mar 28, 2012 at 6:47 AM, Kem Tekinay
> <<email address removed>>wrote:
>
>> Is there a way to create per-character background color in a TextArea?
>
> Alex Restrepos Custom Editfield has a function for this:
> HighlightCharacterRange(start, length, color, rounded)
>
> http://homepage.mac.com/alexrestrepo/indexmain.html
>
> In many ways it mirrors RBs editfield but I don't think you can switch to
> it by simply changing the super. So it'll take some time to learn it and
> work to refactor but it's really flexible. I highlight RBscript compile
> error lines with this and it looks cool!

I think that is open source now? If so has anybody looked under teh hood on it? is it easy to figure out/modify?

I'm writing a styled text class that will output the wrapped styled text as a group2D and can handle superscripts and subscripts for scientific/chemical applications. Ideally I would want a WYSIWYG... but the RB TextField does not support superscripts and subscripts... I was wondering if Alex's code could be easily modified to hand editing text with those.

Thanks,
- karen
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Character background color in TextArea
Date: 01.04.12 19:44 (Sun, 1 Apr 2012 11:44:07 -0700)
From: William Shank
On Wed, Mar 28, 2012 at 6:47 AM, Kem Tekinay
<<email address removed>>wrote:

> Is there a way to create per-character background color in a TextArea?

Alex Restrepos Custom Editfield has a function for this:
HighlightCharacterRange(start, length, color, rounded)

http://homepage.mac.com/alexrestrepo/indexmain.html

In many ways it mirrors RBs editfield but I don't think you can switch to
it by simply changing the super. So it'll take some time to learn it and
work to refactor but it's really flexible. I highlight RBscript compile
error lines with this and it looks cool!
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Character background color in TextArea
Date: 31.03.12 18:37 (Sat, 31 Mar 2012 10:37:07 -0700)
From: Myron Meyer
A couple of additional thoughts:
If the Parent Canvas is of inside of the TextArea in the IDE, the Clones
will scroll with the text (the TextArea is the Parent).
How to instantiate the clone via code at the right time, place & size I
haven't figured out yet.
As far as figuring out the coordinates of the text, any given text size is
a defined number of pixels, points etc.,
so a count of the number of lines preceeding, multiplied by the Text
Height, should give you the top of the text you want to Hilite.
It seems that no matter what your final solution is, you will need a way
to find the start point.
Almost all of the Apps I have worked on so far have been Graphics
oriented, so I have little experience with TextAreas and
text manipulation. I did some research in the UsersGuide and it seems that
one possible (and relativly easy) solution
would be to change the text color, rather than trying to simulate a Hiliter.
Possibly using the SelTextColor in conjunction with SelStart and SelLength,
although I,m sure there are other options.
Myron

On Fri, Mar 30, 2012 at 11:15 PM, Myron Meyer <<email address removed>> wrote:

> Now I have a better idea of what you are trying to accomplish.
> If the user is not inputting the text, then possibly you could use a
> "Scrollable" Canvas instead of a TextArea - i.e. draw the text in the
> Canvas, then the hiliting becomes much easier to impliment - draw the
> rectangles where ever you need them & they will scroll along with the text.
> Myron
> On Fri, Mar 30, 2012 at 3:02 PM, Kem Tekinay <
> <email address removed>> wrote:
>
>> Your suggestion is intriguing and might work for static text, but not in
>> my case. I would need to change the background color of the text
>> programmatically, not as a response to a user action, and it would have to
>> follow the text as the user scrolls. If I could determine the XY
>> coordinates of text within the control, I could probably implement a
>> version of your excellent suggestion, but alas, I cannot.
>>
>> What I really want is a "BackgroundTextColor" within StyledText. I guess
>> I can put that in as a request, or I can check to see if it's in the MBS
>> plugins.
>>
>> On Mar 30, 2012, at 5:28 PM, Myron Meyer wrote:
>>
>> > Use Clone Canvases that have a filled Rectangle (semi Transpatent
>> > ForeColor) to Hilite the text.
>>
>> --
>> Kem Tekinay
>> MacTechnologies Consulting
>> (212) 201-1465
>> (914) 242-7294 Fax
>> http://www.mactechnologies.com/
>>
>> _______________________________________________
>> Unsubscribe or switch delivery mode:
>> <http://www.realsoftware.com/support/listmanager/>
>>
>> Search the archives:
>> <http://support.realsoftware.com/listarchives/lists.html>
>>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Character background color in TextArea
Date: 31.03.12 07:15 (Fri, 30 Mar 2012 23:15:17 -0700)
From: Myron Meyer
Now I have a better idea of what you are trying to accomplish.
If the user is not inputting the text, then possibly you could use a
"Scrollable" Canvas instead of a TextArea - i.e. draw the text in the
Canvas, then the hiliting becomes much easier to impliment - draw the
rectangles where ever you need them & they will scroll along with the text.
Myron
On Fri, Mar 30, 2012 at 3:02 PM, Kem Tekinay
<<email address removed>>wrote:

> Your suggestion is intriguing and might work for static text, but not in
> my case. I would need to change the background color of the text
> programmatically, not as a response to a user action, and it would have to
> follow the text as the user scrolls. If I could determine the XY
> coordinates of text within the control, I could probably implement a
> version of your excellent suggestion, but alas, I cannot.
>
> What I really want is a "BackgroundTextColor" within StyledText. I guess I
> can put that in as a request, or I can check to see if it's in the MBS
> plugins.
>
> On Mar 30, 2012, at 5:28 PM, Myron Meyer wrote:
>
> > Use Clone Canvases that have a filled Rectangle (semi Transpatent
> > ForeColor) to Hilite the text.
>
> --
> Kem Tekinay
> MacTechnologies Consulting
> (212) 201-1465
> (914) 242-7294 Fax
> http://www.mactechnologies.com/
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Character background color in TextArea
Date: 30.03.12 23:02 (Fri, 30 Mar 2012 18:02:23 -0400)
From: Kem Tekinay
Your suggestion is intriguing and might work for static text, but not in my case. I would need to change the background color of the text programmatically, not as a response to a user action, and it would have to follow the text as the user scrolls. If I could determine the XY coordinates of text within the control, I could probably implement a version of your excellent suggestion, but alas, I cannot.

What I really want is a "BackgroundTextColor" within StyledText. I guess I can put that in as a request, or I can check to see if it's in the MBS plugins.

On Mar 30, 2012, at 5:28 PM, Myron Meyer wrote:

> Use Clone Canvases that have a filled Rectangle (semi Transpatent
> ForeColor) to Hilite the text.

Re: Character background color in TextArea
Date: 30.03.12 22:28 (Fri, 30 Mar 2012 14:28:30 -0700)
From: Myron Meyer
Kem -
I'm pretty much a novice at programming, but I think I have something that
might work for you.
Use Clone Canvases that have a filled Rectangle (semi Transpatent
ForeColor) to Hilite the text.
I worked up an example for you to try. This was done with Antique WindowsXP
so it is necessary to check
UseGDIplus in the Project App. Also in the App Open EventHandler this line
of Code:
app.UseGDIPlus=true.
I don't know if this is necessary for Mac.

Properties needed:
DragDeltaX as integer
DragDeltaY as integer
YeloHilite as Boolean = True
RedHilite as Boolean = False
// Add as many colors as you want for HiLiter Colors

In the MouseDown EventHandler of your TextArea:
dim i as integer
// This sets the Clone Canvas Height slightly larger than the TextSize (I
didn't try this in a TextArea with
// StyledText so I don't know if TextSize changes in the body will be
recognized.
// The Hilite Canvas is Resizeable though)

Select Case me.TextSize
case 10
i
case 12
i
case 14
i
case 16
i
end select

if Keyboard.AltKey then // Use whatever key suit your purposes and OS

dim c as Canvas
c= new HiLiter // HiLiter is the Parent Canvas name in the IDE
c.Visible=true // The Parent Canvas is Visibleúlse in the Open
EventHandler of the Canvas
c.Top=MouseY- HiLiter(0).Height/2 // Centers the Canvas Y coordinate on
the Cursor
c.Left= MouseX // The Canvas will be instantiated to the right of the
Cursor
c.Name="Hilite" // The name can be used with a control count to close
all of the Clones
c.Height= i // Height is determined with the SelectCase statement above
c.Invalidate

end if

In the Canvas EventHandlers
Open:
me.Visibleúlse // Visible has to be set to True in the IDE.

Paint:
// Use as many Color/Booleans as you need
if YeloHilite = True then
g.ForeColor = RGB(255,255,000,200) // RGB(RRR,GGG,BBB,Transparency
factor - 000 = Opaque / 255 = Transparent)
elseif RedHilite = true then
g.ForeColor = RGB(255,000,000,200)
end if
g.FillRect 0,0,me.Width,me.Height

MouseDown:
//MouseDown of a control: Used to drag the Canvas - ( this was given to
me by another Nug subscriber in answer to a

// question I once asked)
DragDeltaX=self.MouseX-me.Left
DragDeltaY=self.MouseY-me.Top

if Keyboard.AltKey then me.Close // This will close which ever Clone is
Clicked on - Use whatever Key that suits your needs
Return True // important line

MouseDrag:
//MouseDrag of a control: Used to drag the Canvas - ( this was given to
me by another Nug subscriber in
// answer to a question I once asked - the second part of the answer)

if Keyboard.ShiftKey then // Use whatever key suit your purposes and OS
me.Left=self.MouseX-DragDeltaX
me.Top=self.MouseY-DragDeltaY

else // Modified from above to resize the Clone Canvas
me.Left=me.Left
me.WidthÐagDeltaX-me.left+self.MouseX // Adjust the Width

me.top=me.top
me.heightÐagDeltaY-me.top+self.MouseY // Adjust the height to Hilite
an entire paragraph or more if needed

end if

This was used in a BevelButton with a menu to change the Hilite Color. It
could be any MenuItem, Popup, Contextual:
if me.MenuValuethen
me.Caption="Yellow"
RedHiliteúlse
YeloHilite=true
elseif me.MenuValuethen
me.Caption="Red"
YeloHiliteúlse
RedHilite=true
end if
I believe this is everything necessary to make this work - I hope it's
useful
Myron

On Wed, Mar 28, 2012 at 6:47 AM, Kem Tekinay
<<email address removed>>wrote:

> Is there a way to create per-character background color in a TextArea? I
> want to simulate the effect of highlighting words or paragraphs on a page
> with a marker.
>
> --
> Kem Tekinay
> MacTechnologies Consulting
> (212) 201-1465
> (914) 242-7294 Fax
> http://www.mactechnologies.com
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>