Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 9:16 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Button Text Selection problem
PostPosted: July 13th, 2010, 10:27 pm 
Offline

Joined: December 14th, 2004, 5:08 pm
Posts: 55
Location: Holland
Opus: version 8.0
OS: XP, Vista, Windows7, Windows8
System: Intel Corei7-2600 CPU 3.400GHz
Hi,

I have 44 ButtonObjects containing on each button text "A1" t'ill "A44". Text font on buttons is Arial
I want to change the font text of each button

var new_style = new Object();
var getTextButton = Button1.GetFirstChild();
getTextButton.SetSelection(0,-1) ;
new_style.fontname = "Century Gothic"
getTextButton.SetSelectionStyle(new_style);

So far so good...
Now when I move my cursor over the buttons , the button style change back to default (Arial)

How do I script the button object even when the cursor is moving over the the button the text still is Century Gothic?

Thanks in advance for the help

Jim


Opus Version7.03 on OS:XP


For this message ivisionar has been thanked by : mackavi


Last edited by ivisionar on July 14th, 2010, 12:05 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Button Text Selection problem
PostPosted: July 13th, 2010, 11:23 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
You need to post your profile so that we know what Opus version we're dealing with.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: Button Text Selection problem
PostPosted: July 15th, 2010, 1:10 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Hi Jim,

Thanks for the information.

It does explain this in the help - saying that changes to the Button's text changes back on mouse over. Doesn't help you though! There are several possible workarounds depending on how you're using the buttons. I'd opt for this if it works for you:

As you've discovered there is a textbox object as one of the children of the button. It's this object that changes when the button is interacted with. However, because this is an object it can be cloned.

Using your script, firstly clone the child object, then hide the original child object, then apply the settings to the clone instead. For further changes you'll have to call the new child or attach the TB object as a property of the button object for easy access. I haven't tested but I'd assume the Button States 'change text' will now fail and you'll have to use a custom script instead for this (but then we had to do this in older versions of Opus anyway).

Regards,

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: Button Text Selection problem
PostPosted: July 15th, 2010, 2:15 pm 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 512
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
Would there be any advantage in not using buttons, but create buttons from vectors with a text object (Text1) sitting over it. That way you don't suffer from reverting to the old font style on mouse over? You can make the vector look like a button by adding a button border.

Code:
var new_style = new Object();
Text1.SetSelection(0,-1) ;
new_style.fontname = "Century Gothic"
Text1.SetSelectionStyle(new_style);






Sandy

_________________
Whoever designed this, never actually used it!


For this message sandyn has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Button Text Selection problem
PostPosted: July 15th, 2010, 3:22 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Jim,

Quote:
Text font on buttons is Arial. I want to change the font text of each button
First I want to be clear -- you need to do this when the User is running the Pub? (and not do this as part of the design process in the Opus Editor? -- where you can establish different Fonts for different Button states [stating the obvious :) ] ).

So what are you planning as the trigger event here?
I ask because at first it sounded like you wanted to "change" all 44 Buttons at once? Maybe this is some sort of User preferences you're trying to implement?

Quote:
Now when I move my cursor over the buttons , the button style change back to default (Arial)
How do I script the button object even when the cursor is moving over the the button the text still is Century Gothic?
Simply use the same 5 lines of code you showed in your first post. If you put that code in a Function defined in a Script Object, simply call that function with a MouseOver trigger on each Button.

Depending on what you are trying to do, you could change this:
new_style.fontname = "Century Gothic"
to this: new_style.fontname = myVariableFont ;

...and then provide a Listbox with a list of font names: e.g., Century Gothic, Calibri, whateverFont
You could add a MouseClick trigger to the LB and call that same function above to make the change.
[Lar EDIT:] I'll leave this idea here, but I seem to recall that using a variable may not work. Or maybe you would need to concatenate to add opening and closing quotemarks. I do not remember if the obstacle was related to 'GetAttributes' or 'GetDisplayData' or similar. [/edit]

(BTW, when creating an action that you want to apply to many objects (44 buttons), you can create it once and then Select that Trigger, Copy it, leave the dialogue box open while selecting the next Button, then Paste that Trigger along with its actions on that object. Repeat for the other objects.).


One last suggestion:
Code:
var getTextButton = Button1.GetFirstChild();
Can be done with:
Code:
var getTextButton = Button1.GetTextObject();
But either way will work.

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Last edited by Lar_123 on July 15th, 2010, 7:24 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Button Text Selection problem
PostPosted: July 15th, 2010, 4:25 pm 
Offline

Joined: December 14th, 2004, 5:08 pm
Posts: 55
Location: Holland
Opus: version 8.0
OS: XP, Vista, Windows7, Windows8
System: Intel Corei7-2600 CPU 3.400GHz
Hi Lar,

While running the pub. We have made two publications 1) the user can change some colors and fonts (while pub is running call it user preferences) and 2) a publication which runs on a touchscreen reading the user preferences.

So in the first pub a user can change font and color when a button object is up or down. In the second pub we see the changes.

Yes, the mouse over trigger does the job....is already along time ago I used this...little bit rusty here :-)

Although the text frames and place it over the buttons works very well to.....

Thank you.....working like a charm...

Jim


For this message ivisionar has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Button Text Selection problem
PostPosted: March 14th, 2012, 1:26 pm 
Offline

Joined: May 25th, 2008, 4:57 pm
Posts: 355
Location: Ireland
Opus: Pro 9.75
OS: Windows 10
System: MacBook Pro (Intel 2020)
I think having text on a button behave in the same way that text objects do in future versions of Opus would be very helpful, allowing us to manipulate the text with greater ease via script.

Another option, but won't work for all is to convert the button to a Text Object. But you will loose some of the button mouse over features and control.

_________________
Opus Pro 9.75 on MacBookPro (2020 Intel) running Parallels 19 with Windows 10 (x64)


For this message lmc has been thanked by : mackavi


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 46 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group