Text Box - can color (gray vs. white) change with Edit true/false status?

If I put a text box in a dialog box, I can flag it as editable or not, which controls the initial background color (gray or white) of the text box.

But if I subsequently change the edit status, the background color does not change.
So for now I opted to put up the text box as editable, and use the inactive()/active() functions to alter the display state of the text box.

However I'd rather have the background color just change states when editability changes.
Is there no way to accomplish this?

Regards,
Strathglass
strathglass - Mon Mar 02 11:56:28 EST 2009

Re: Text Box - can color (gray vs. white) change with Edit true/false status?
kbmurphy - Mon Mar 02 14:16:41 EST 2009

In DOORS, you show and hide dialog boxes. So a box is either visible, and its elements active/enabled, or it's hidden.

Unless I am mistaken, you cannot change the background color of a standard dialog box. The background color of the dialog box is either determined by the user's DOORS settings, or the user's Windows settings.

You could use a canvas and paint on it when you want the box to be shown as "active"...

Re: Text Box - can color (gray vs. white) change with Edit true/false status?
llandale - Mon Mar 02 15:26:09 EST 2009

Yes, the following demonstrates it:

//*** Start DXL
DB db
DBE dbe

void applyRead(DB dbXX)
{
bool IsRead = get(dbe)
set(dbe, !IsRead)
realize(db)
show db
}

db = create("DD")
dbe = text(db, "TextBox", "Initial", 70, false)
apply(db, "Change Read", applyRead)
show db
//**** END DXL

Hit the apply button a few times, each time trying to edit in the box. Half the time you can.

Curious, the background color of the DBE doesn't change when you change its Read/Write state in the applyRead callback.

You know, you CAN have two text DBEs with the same size with positions one exactly over the other, and instead of changing the Read/Write status of 'the' DBE, you can 'show' then one you want and 'hide' the one you don't want:
//******** BEGIN DXL **********

bool g_Showing1 = false // Showing dbe1

DB db
DBE dbe0, dbe1, dbe2

void applyRead(DB dbXX)
{ string CurrVal
if (g_Showing1)
{ CurrVal = get(dbe1)
set(dbe2, CurrVal)
hide(dbe1)
show(dbe2)
}
else
{ CurrVal = get(dbe2)
set(dbe1, CurrVal)
hide(dbe2)
show(dbe1)
}
g_Showing1 = !g_Showing1
}

db = create("DD")
dbe0 = label(db, "")
dbe1 = text(db, "TextBox 1", "Initial 1", 100, 70, false)
dbe2 = text(db, "TextBox 2", "Initial 2", 100, 70, true)
// dbe1 ->"top" ->"aligned" ->dbe2 // this din't work. Odd.
dbe2 ->"top" ->"spaced" ->dbe0
apply(db, "Change Read", applyRead)

applyRead(db)

show db
//************* END DXL **********

Oddly, aligning the top of dbe2 to dbe1 ended up clearing the box of dbe1, very odd. Spacing dbe2 to a blank label above dbe1 seems to work; oh well.

Notice the clever way of getting the current value of the displayed dbe and setting it to the other, before hiding the displayed and displaying the other. Now if you make the labels the same, the user won't know you are swaping DBEs.

Nerds like this sort of clever get-arounds.

  • Louie

Re: Text Box - can color (gray vs. white) change with Edit true/false status?
ePiallat - Tue Mar 03 03:04:45 EST 2009

llandale - Mon Mar 02 15:26:09 EST 2009
Yes, the following demonstrates it:

//*** Start DXL
DB db
DBE dbe

void applyRead(DB dbXX)
{
bool IsRead = get(dbe)
set(dbe, !IsRead)
realize(db)
show db
}

db = create("DD")
dbe = text(db, "TextBox", "Initial", 70, false)
apply(db, "Change Read", applyRead)
show db
//**** END DXL

Hit the apply button a few times, each time trying to edit in the box. Half the time you can.

Curious, the background color of the DBE doesn't change when you change its Read/Write state in the applyRead callback.

You know, you CAN have two text DBEs with the same size with positions one exactly over the other, and instead of changing the Read/Write status of 'the' DBE, you can 'show' then one you want and 'hide' the one you don't want:
//******** BEGIN DXL **********

bool g_Showing1 = false // Showing dbe1

DB db
DBE dbe0, dbe1, dbe2

void applyRead(DB dbXX)
{ string CurrVal
if (g_Showing1)
{ CurrVal = get(dbe1)
set(dbe2, CurrVal)
hide(dbe1)
show(dbe2)
}
else
{ CurrVal = get(dbe2)
set(dbe1, CurrVal)
hide(dbe2)
show(dbe1)
}
g_Showing1 = !g_Showing1
}

db = create("DD")
dbe0 = label(db, "")
dbe1 = text(db, "TextBox 1", "Initial 1", 100, 70, false)
dbe2 = text(db, "TextBox 2", "Initial 2", 100, 70, true)
// dbe1 ->"top" ->"aligned" ->dbe2 // this din't work. Odd.
dbe2 ->"top" ->"spaced" ->dbe0
apply(db, "Change Read", applyRead)

applyRead(db)

show db
//************* END DXL **********

Oddly, aligning the top of dbe2 to dbe1 ended up clearing the box of dbe1, very odd. Spacing dbe2 to a blank label above dbe1 seems to work; oh well.

Notice the clever way of getting the current value of the displayed dbe and setting it to the other, before hiding the displayed and displaying the other. Now if you make the labels the same, the user won't know you are swaping DBEs.

Nerds like this sort of clever get-arounds.

  • Louie

To stack your textboxes without an extra dbe you have to use this:

db = create("DD")
dbe1 = text(db, "TextBox 1", "Initial 1", 100, 70, false)
dbe2 = text(db, "TextBox 2", "Initial 2", 100, 70, true)
dbe1 -> "bottom" -> "form"
dbe2 -> "top" -> "aligned" ->dbe1

apply(db, "Change Read", applyRead)

As (dbe1 -> "bottom") is unattached first, and (dbe2 -> "top") spaced to (dbe1 -> "bottom"), if you try to attach dbe1->"top" to dbe2, you create an unresolvable circular reference.

What is really odd however is that the "stacked(DBE)" perm does not work for text elements...

Re: Text Box - can color (gray vs. white) change with Edit true/false status?
strathglass - Tue Mar 03 08:11:26 EST 2009

Thanks Louie.
Like you, I was surprised the background colour doesn't change when you change its read/write state - that was the problem I wanted to solve.
I was hoping there would be a simpler solution, but I guess not.
However your work around is very effective and works perfectly, thank you!

kbmurphy - yes, you show/hide DBs, but you can also activate/inactivate DBEs, like textBox DBEs. And for textBox DBEs, the background is gray if it is created as read-only, but white if create read/write. Unfortunately, subsequent changes to its editability do not cause the intial background colour to change (which is what I wanted). So my solution was to activate/inactivate a read/write textBox DBE: this way, it went from white, to gray but obscured (not really the ideal solution). Louie has proposed an effective solution however!

Regards,
Strathglass.

Re: Text Box - can color (gray vs. white) change with Edit true/false status?
strathglass - Tue Mar 03 08:17:43 EST 2009

By the way, there is one down side to Louie's solution:
if you resize the DB, then weird things happen.
EG one DBE resizes, but the other does not!
(Not sure if there is a way to get resize events to account for this)

-strathglass

Re: Text Box - can color (gray vs. white) change with Edit true/false status?
strathglass - Tue Mar 03 10:26:00 EST 2009

ePiallat - Tue Mar 03 03:04:45 EST 2009
To stack your textboxes without an extra dbe you have to use this:

db = create("DD")
dbe1 = text(db, "TextBox 1", "Initial 1", 100, 70, false)
dbe2 = text(db, "TextBox 2", "Initial 2", 100, 70, true)
dbe1 -> "bottom" -> "form"
dbe2 -> "top" -> "aligned" ->dbe1

apply(db, "Change Read", applyRead)

As (dbe1 -> "bottom") is unattached first, and (dbe2 -> "top") spaced to (dbe1 -> "bottom"), if you try to attach dbe1->"top" to dbe2, you create an unresolvable circular reference.

What is really odd however is that the "stacked(DBE)" perm does not work for text elements...

Thanks for that update ePiallat - didn't see it before posting my other replies above.
This will help.

-Strathglass

Re: Text Box - can color (gray vs. white) change with Edit true/false status?
llandale - Tue Mar 03 18:42:52 EST 2009

strathglass - Tue Mar 03 08:17:43 EST 2009
By the way, there is one down side to Louie's solution:
if you resize the DB, then weird things happen.
EG one DBE resizes, but the other does not!
(Not sure if there is a way to get resize events to account for this)

-strathglass

If you add then following after the 2nd text declaration, it resizes OK:
label(db, "")

That is, you can put your text DBEs in the middle of the diagram. If you want it at the bottom and resized, use this instead of the above:
dbe1 ->"bottom" ->"form"

>Louie

Re: Text Box - can color (gray vs. white) change with Edit true/false status?
a_vestlin - Wed Mar 04 05:30:53 EST 2009

You can use the rich text box instead. There the behaviour is as expected.

I have also noticed that the text and richText DBE elements behave differently when it comes to alignement.

/Anders

Re: Text Box - can color (gray vs. white) change with Edit true/false status?
UchihaItachi - Sun Dec 22 22:27:56 EST 2013

a_vestlin - Wed Mar 04 05:30:53 EST 2009
You can use the rich text box instead. There the behaviour is as expected.

I have also noticed that the text and richText DBE elements behave differently when it comes to alignement.

/Anders

Agreed. Rich text box can bring a lot of convenience much than what a text box component can do.

Re: Text Box - can color (gray vs. white) change with Edit true/false status?
Mathias Mamsch - Mon Dec 23 09:28:24 EST 2013

UchihaItachi - Sun Dec 22 22:27:56 EST 2013

Agreed. Rich text box can bring a lot of convenience much than what a text box component can do.

Lets all agree to a couple of very old posts ... I would love to get some agreements from you guys ;-) Regards, Mathias