Code bold selected text

Questions, tips and tricks and techniques for scripting in Servoy

Code bold selected text

Postby Leendert » Mon Sep 14, 2009 11:51 am

How can I set the selected text of a RTF field bold or unbold without the use of the Servoy toolbar?

In other words, I want the same functionallity as the bold button of the Servoy toolbar programmed out under my own button.

Does anyone have an idea or an example?
Leendert Plug

Servoy Developer
Version: 5.1.0 - build 956
Java version 1.6.0_17 (Windows 7)
db: Oracle 10GR2
User avatar
Leendert
 
Posts: 64
Joined: Tue Oct 02, 2007 1:44 pm
Location: Hengelo, Netherlands

Re: Code bold selected text

Postby jcompagner » Mon Sep 14, 2009 3:55 pm

Its not possible to just call the same thing that the action does

You could look what really is changed for a rtf field and just recreate that behavior is scripting.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Code bold selected text

Postby Leendert » Tue Sep 15, 2009 9:25 am

Is it possible to make a plugin that simulates that behavior?
Leendert Plug

Servoy Developer
Version: 5.1.0 - build 956
Java version 1.6.0_17 (Windows 7)
db: Oracle 10GR2
User avatar
Leendert
 
Posts: 64
Joined: Tue Oct 02, 2007 1:44 pm
Location: Hengelo, Netherlands

Re: Code bold selected text

Postby jcompagner » Tue Sep 15, 2009 10:04 am

it could but i dont think that is really easy to do because some are a bit internal
But if you know Swing and the JEditorPane/StyleEditorKit then i think something like this:

plugins.text.setBold(elements.rtffield)

could work
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Code bold selected text

Postby Harjo » Tue Sep 15, 2009 1:43 pm

something maybe related,
what we do, is placing the text toolbar right at the top of the RTF or HTML-AREA, instead at the top only..

you can do this with the menubar plugin in 4. or the it2be menubar plugin in Servoy 3.5.
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Code bold selected text

Postby mboegem » Fri Sep 25, 2009 4:32 pm

Harjo wrote:what we do, is placing the text toolbar right at the top of the RTF or HTML-AREA, instead at the top only..


Interesting... Harjo are you willing to share a codesnippet for this?
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1752
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Code bold selected text

Postby Harjo » Fri Sep 25, 2009 4:42 pm

ofcourse! as always ;-)

place a bean: jToolbar on the place you want the toolbar and name it: text_toolbar
than in the onShow of that form I do:

Code: Select all
plugins.menubar.addServoyToolBar(elements.text_toolbar, 'text')


that's it!
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Code bold selected text

Postby Hans Nieuwenhuis » Sat Sep 26, 2009 9:36 am

Hi Harjo,

Since you also use text markup :

I notice a problem in the userinterface, it is not displaying the actual status of (for instance) the bold setting.

See first picture below :

i inserted 4 lines of text and then selected part of the second line and set it to underlined.
p123.png
p123.png (18.46 KiB) Viewed 8373 times


then i put the cursor at the end of the last line and start typing. The Underline icon is still highlighted.
However, when is start typing the text is not underlined.
When i then deselect the underline setting and start typing the typed text gets underlined.
See second picture.
p45.png
p45.png (18.11 KiB) Viewed 8373 times

This is very confusing for the user.
Also when the user puts the cursor in an underlined section of the text, the underline icon in the toolbar is not activated.

Regards,
Hans Nieuwenhuis
Betagraphics
http://www.deltics.nl
http://www.betagraphics.nl

Servoy Version 7.3.1
Java version 1.7.0.x
Database Oracle 11g
User avatar
Hans Nieuwenhuis
 
Posts: 1026
Joined: Thu Apr 12, 2007 12:36 pm
Location: Hengelo, The Netherlands

Re: Code bold selected text

Postby Harjo » Sat Sep 26, 2009 10:29 am

yeah I know, it's not the best text editor.
but it will do for the stuff we use.
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Code bold selected text

Postby mboegem » Sat Sep 26, 2009 11:34 pm

Harjo wrote:ofcourse! as always ;-)


thnkx! Looks nice and.... easy to do!
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1752
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Code bold selected text

Postby jasantana » Thu Aug 04, 2011 1:29 pm

Harjo wrote:ofcourse! as always ;-)

place a bean: jToolbar on the place you want the toolbar and name it: text_toolbar
than in the onShow of that form I do:

Code: Select all
plugins.menubar.addServoyToolBar(elements.text_toolbar, 'text')


that's it!


Hi Harjo, menubar plugin is not available in Servoy6, how can you do this now?

I would like to show a modal form with a RTF_Area with the text toolbar inside that form.

Thanks
Best regards,
Juan Antonio Santana Medina
jasantana@nephos-solutions.co.uk
Servoy MVP 2015
Servoy 6.x - Servoy 7.x - Servoy 8.x - MySQL - PostgreSQL - Visual Foxpro 9
User avatar
jasantana
 
Posts: 555
Joined: Tue Aug 10, 2010 11:40 am
Location: Leeds - West Yorkshire - United Kingdom

Re: Code bold selected text

Postby ROCLASI » Thu Aug 04, 2011 1:52 pm

jasantana wrote:Hi Harjo, menubar plugin is not available in Servoy6, how can you do this now?

Hmm..it's there alright.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Code bold selected text

Postby jcompagner » Thu Aug 04, 2011 2:05 pm

isn't it called window?
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Code bold selected text

Postby ROCLASI » Thu Aug 04, 2011 2:08 pm

Heh, I see the function toolbar and think immediately about plugins.window.*. Totally not seeing that you wrote plugins.menubar.* . :oops:
The menubar plugin was integrated into the window plugins a few versions back.

Hope this helps.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Code bold selected text

Postby jasantana » Thu Aug 04, 2011 2:14 pm

Robert I got it.


Code: Select all
var win = application.createWindow(application.getUUID().toString(), JSWindow.MODAL_DIALOG);
win.title='Edición Modelo Contrato';
win.showTextToolbar(true);     // THIS DOES THE TRICK
forms.frmEdicionContratoLOPD_GSDespachos.controller.show(win);
Best regards,
Juan Antonio Santana Medina
jasantana@nephos-solutions.co.uk
Servoy MVP 2015
Servoy 6.x - Servoy 7.x - Servoy 8.x - MySQL - PostgreSQL - Visual Foxpro 9
User avatar
jasantana
 
Posts: 555
Joined: Tue Aug 10, 2010 11:40 am
Location: Leeds - West Yorkshire - United Kingdom


Return to Methods

Who is online

Users browsing this forum: No registered users and 16 guests