Page 1 of 1
How to right-justify a StringGadget?
Posted: Thu Jan 08, 2015 10:54 pm
by IdeasVacuum
How can a StringGadget() be flagged to be right-justified? Is this native to javascript? There seems to be plenty of right-justified boxes about?
Tried:
Code: Select all
EnableJS
document.getElementById(7).style.textAlign="right";
DisableJS
But get error from Browser Console:
Code: Select all
TypeError: document.getElementById(...) is null
.........It's important that numbers are displayed right-justified
Re: How to right-justify a StringGadget?
Posted: Mon Apr 13, 2015 5:48 am
by netmaestro
Hint: You can get the correct id of an element by right-clicking it in your browser and select "Inspect Element". I did that and was able to code this, my very first working SpiderBasic program:
Code: Select all
If OpenWindow(0, 0, 0, 322, 205, "StringGadget Flags", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StringGadget(0, 8, 10, 306, 20, "Right Justified StringGadget...")
EnableJS
var x = document.getElementById("dijit_form_TextBox_0");
x.style.textAlign = "right";
DisableJS
EndIf
It's remarkable how many times I try to use css syntax like "text-align" in js where only "textAlign" will work. Seriously, why they don't harmonize the syntax is beyond me. I have to look up who to send the bill to for all these bruises on my head.
Re: How to right-justify a StringGadget?
Posted: Mon Apr 13, 2015 6:49 pm
by eddy
Code: Select all
Procedure SetStringGadgetStyle(Id,style$,value$)
!spider_GadgetID(v_id).gadget.textbox.style[v_style$]=v_value$
EndProcedure
If OpenWindow(0, 0, 0, 322, 205, "StringGadget Flags", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
;right to left
StringGadget(1, 10, 10, 300, 20, "Right Justified StringGadget...")
SetStringGadgetStyle(1,"direction","rtl")
SetStringGadgetStyle(1,"unicode-bidi","bidi-override")
;align right
gadgetId=StringGadget(#PB_Any, 10, 40, 300, 20, "Right Justified StringGadget...")
SetStringGadgetStyle(gadgetId,"text-align","right")
EndIf