david wrote:Say I have the following statements in a method which control the look of a button on a custom controller. The method is called when the form is entered:
forms.controller_main.elements.b_nav_branch_info.text="<html><b>Branch Info</b>";
forms.controller_main.elements.b_nav_branch_info.bgcolor="white";
I have a similar method that is called when the form is exited:
forms.controller_main.elements.b_nav_branch_info.text="<html>Branch Info";
forms.controller_main.elements.b_nav_branch_info.bgcolor="#D3D3D3";
The name of the form is "branch_info". By the time I am done, I could have dozens of forms and I will need both of these methods for each form. Instead of duplicating each of these methods and inserting the correct form name for each form, is it possible to reuse one instance of each method (global method) and substitute the current form name on the fly? Sort of like this:
forms.controller_main.elements.b_nav_<<insert_current_form_name>>.text='<html>Branch Info';
forms.controller_main.elements.b_nav_<<insert_current_form_name>>.bgcolor="#D3D3D3";
Hi David,
1) create a global text "contentButtonX"
2) go into designer, create buttonX.
3) set the property "dataprovider" of buttonX to globals.contentButtonX
4) in the MethodEditor create a global script that goes like this:
------
globals.contentButtonX='<html>' +
' <table width=80>' +
' <td bgcolor = "#D3D3D3" align = "left">'+currentcontroller.getName()+'</td>' +
' </table>'
------
NOTES:
-literal text goes between single quotes
-set the width to the same size as your button. (this way you can use HTML alignment properly
-assign this global script to property "onShow" of your form
(of course you may use the other "event" properties as well)
-you can now attach this script to any button/form in your solution
TIPS:
-you may also want to store your html code in separate globals:
globals.HTMLleft + currentcontroller.getName() + globals.HTMLright
-or globals.bgcolor
(important: globals aren't stored when you close a solution, so best thing to do in this case is create a separate table called settings or main with one record in it, having fields HTMLleft, HTML right, HTMLbgcolor etc..)
last note:
We're testing code right now, using images on buttons.
We already have "rollOverImage"(onMouseOver) that switches images in a button , but we also want to create the possibility to change image with a scriptstep. Hopefully in the next build, but I can't promise right now.
Have fun!