Integrated Application Platform › Forums › General › How to show left text for boolean field control? › Re: Re: How to show left text for boolean field control?
September 11, 2014 at 2:35 am
#1108
Participant
thanks andrew, I have modified two standard objects and it now seems to be working as I expected.
1) CheckBoxPairControl
Following changes make the text show on the left for CheckBox control.
PassthruController{
Name: 'CheckBoxPair'
New(prompt, checkbox, hidden = false) // old: (checkbox, prompt, hidden = false)
{
super(.layout(prompt, checkbox, hidden)) // old: (checkbox, prompt, hidden)
c = .Horz.GetChildren()
// old
//.box = c[0]
//.text = c[2]
//.Ymin = .box.Ymin
//.Top = .box.Top
// old
// new
.text = c[0]
.box = c[2]
.Ymin = .text.Ymin
.Top = .text.Top
// new
}
layout(prompt, checkbox, hidden) //old: (prompt, checkbox, hidden)
{
text = Object('Static', prompt, notify:, hidden: hidden)
for m in #(font, size, weight)
if checkbox.Member?(m)
text[m] = checkbox[m]
//old: return Object('Horz', checkbox, #('Skip', 3), text)
return Object('Horz', text, #('Skip', 3), checkbox)
}
Get()
{
.box.Get()
}
Set(val)
{
.box.Set(val)
}
SetFocus()
{
.box.SetFocus()
}
BnSetFocus()
{
.text.DrawFocusRect(true)
}
BnKillFocus()
{
.text.DrawFocusRect(false)
}
Static_Click()
{
if .box.GetEnabled()
{
.box.SetFocus()
.box.Set(not .box.Get())
.box.BN_CLICKED()
}
}
}
2) Construct method in Control object
On Access control, I could not make the text align with the rest of the textboxes. But if I comment out the code concerning ‘prompt isn’t greyed’ for CheckBox, it aligns with others nicely and prompt isn’t greyed in protect mode. Is it safe to do it like this?
Construct(@x)
{
if (x.Size() is 1 and x.Member?(0) and Object?(x[0]))
x = x[0]
if (x[0] is 'NoPrompt' and String?(x[1]) and x[1] =~ "^[_a-z]")
{
c = x
x = Datadict(x[1]).Control.Copy().Add(x[1] at: 'name')
for m in c.Members()
if String?(m)
x[m] = c[m]
}
else if (String?(x[0]) and x[0] =~ "^[_a-z]")
{
name = x[0]
dict = Datadict(name)
x = dict.Control.Copy()
hidden = false
if .Custom isnt false and .Custom.Member?(name)
{
x.Merge(.Custom[name])
hidden = .Custom[name].GetDefault('hidden', false)
}
x.name = name
if "" isnt prompt = Prompt(name)
{
//if x[0] is 'CheckBox'
//x = Object('CheckBoxPair', x, prompt, hidden: hidden)
// need this so prompt isn't greyed when protected
//else
x = Object('Pair', Object('Static', prompt, hidden: hidden), x)
}
}
_parent = this
_ctrlspec = x
ctrl = Construct(x, "Control")
if (ctrl.Name > "")
this[ctrl.Name] = ctrl
return ctrl
}