Integrated Application Platform › Forums › General › How to show left text for boolean field control?
- This topic has 4 replies, 2 voices, and was last updated 9 years, 3 months ago by
jaska_lee.
-
AuthorPosts
-
September 10, 2014 at 1:38 am #791
jaska_lee
ParticipantI would like to show the text on the left of the checkbox for boolean fields on access. But the left text option for boolean field control doesn’t seem to be working. It works if you directly add a checkbox,
Window(#(CheckBox 'Allow Bonus' lefttext:))
But it does not show lefttex for boolean controls defined for table fields.
Thanks
September 10, 2014 at 5:33 pm #1107amckinlay
KeymasterIt is a result of Control.Construct and how it uses CheckBoxPairControl.
It probably would not be too hard to fix CheckBoxPairControl to handle it.
(it doesn’t help you, but this has changed in my latest code and now works correctly)
September 11, 2014 at 2:35 am #1108jaska_lee
Participantthanks 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
}September 11, 2014 at 7:57 pm #1109amckinlay
KeymasterThe other reason for CheckBoxPair is to get a focus rectangle on the prompt.
When CheckBoxPair draws the text it handles the focus rectangle, but then it grays out the text when protected.
If you use Pair (like in your changes) then Static draws the text so it is not grayed out, but you do not get a focus rectangle.
Note: With your changes to Control.Construct, CheckBoxPair is not used any more.
If you made your changes to CheckBoxPair but did not change Control then it should work as before.
September 12, 2014 at 3:04 am #1110jaska_lee
Participantif I don’t make the change to construct method, it goes like this(please see the screenshot) and i couldn’t get it align with the rest textboxes.
i see the point of using ‘CheckBoxPair’, however, i actually prefer no rectangle on prompt when clicked.
thanks for the tips andrew. -
AuthorPosts
- You must be logged in to reply to this topic.