How difficult is it to set up a user font styling menu?

Here's where to discuss using Stéphane Leys' very well done alternative runtime editor. If you're a control freak at runtime you have to check this out!

How difficult is it to set up a user font styling menu?

Postby drpitcairn » Sun Dec 20, 2009 2:01 pm

Can I put in a menu that allows the user to make italic, bold, underline, or color text in a field? Can you give me some hints on how that would be done?

Thanks,
Richard
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: How difficult is it to set up a user font styling menu?

Postby johnjohnston1 » Sun Dec 20, 2009 3:09 pm

rpitcairn wrote:Can I put in a menu that allows the user to make italic, bold, underline, or color text in a field? Can you give me some hints on how that would be done?

Thanks,
Richard

hi Richard,
with MPI you would use the menu module.
NB the menu module will create menus, you then need to add:
Code: Select all
insert menu "style"
into your openProject handler.

this might help:
http://www.littlefishsw.co.uk/card/mpi/ ... u_mod.html
There is a short movie to watch. NB a few versions of mpi behind Stéphane.

I've also got a simple script that you can run once, which creates a style menu, again you need to insert the menu when your project opens but if you run this script once it will create a style menu:
http://www.scriptlib.net/index.php?cmd= ... dStyleMenu

cheers

john
User avatar
johnjohnston1
 
Posts: 196
Joined: Sun Jul 06, 2008 10:42 am
Location: Glasgow, UK

Re: How difficult is it to set up a user font styling menu?

Postby drpitcairn » Sun Dec 20, 2009 4:24 pm

John,
Totally useful. I already used your script and have it installed. Thanks so much. I was anticipating a really long drawn out effort and this was so easy!

Best,
Richard
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: How difficult is it to set up a user font styling menu?

Postby drpitcairn » Sun Dec 20, 2009 10:18 pm

Okay, now I am greedy. Can I also add a menu item that allows the font to be a different color?
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: How difficult is it to set up a user font styling menu?

Postby S. Leys » Sun Dec 20, 2009 11:48 pm

rpitcairn wrote:Okay, now I am greedy. Can I also add a menu item that allows the font to be a different color?

If you mean a color palette similar to the one in the MPI menus, the answer is no. Menus of the menu bar can't have palettes, only text items.
But you could look at the PopColors function in the shared script.

S.
User avatar
S. Leys
 
Posts: 628
Joined: Sun Jul 06, 2008 11:03 am

Re: How difficult is it to set up a user font styling menu?

Postby johnjohnston1 » Mon Dec 21, 2009 8:23 am

rpitcairn wrote:Okay, now I am greedy. Can I also add a menu item that allows the font to be a different color?

As Stéphane says you can get a color palette in a menu.
you can have a menu with color names as items which might suit you?

create, with the menu module a new menu, text color.
Create items in that menu:
Red,Blue,Green,Black,White

put this script in the menu, it is not great, but it will work:
Code: Select all
on itemSelect
  if selectedText() is empty then exit itemSelect
  put "Red,Blue,Green,Black,White" into tColors
  put "36,236,112,1,256" into tColorNumbers
  put item (the number of items in char 1 to  offset(the short name of the target,tColors) of tColors ) of tColorNumbers into tColor
  get the selectedChunk
  delete word 1 to 5 of it
  put it into tfield
  set the textColor of tfield to tColor
end itemSelect


hopefully you can see you can make menus to run any script you like

cheers

john
User avatar
johnjohnston1
 
Posts: 196
Joined: Sun Jul 06, 2008 10:42 am
Location: Glasgow, UK

Re: How difficult is it to set up a user font styling menu?

Postby drpitcairn » Wed Dec 23, 2009 5:59 pm

A thing of beauty! Works great. I had to adjust the numbers for black vs. white as they were backwards but I figured it out.
Thanks very much. I have learned a lot.

Richard
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: How difficult is it to set up a user font styling menu?

Postby drpitcairn » Wed Dec 30, 2009 11:46 am

I have been working with putting these menus into my project. Today tried changing the font in an editable text field by using the Font menu. This menu shows all the fonts in my system. What I did was to select text, then choose another font. Problem is there is no effect, no change. So do I have to tweak the font menu in some way?

R.
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona


Return to Using MPI

Who is online

Users browsing this forum: No registered users and 1 guest