Hello
How do I hide text in a field? In Toolbook I could simply use a command like:
hide text of field "ABC"
In runrev, the only way I can achieve this is to change the textcolor to be the same as that of the background. Is there some more generic way of doing this? I may want to change the background of a field and would prefer not to have to run through all my code to change the various textcolors that I may have set.
Many thanks
Andrew Lian
Hiding text in a field
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
Re: Hiding text in a field
There is no such command. However it's not too difficult to implement. I would avoid to change the color of the text as it is too dependent on the formatting of the field itself. Furthermore, changing the color won't change the color of any link. Then, if no more is done than change the color, the user may still be able to select the text and even to cut or modify it (if permitted)mlapl1 wrote:hide text of field "ABC"
Code: Select all
...
put the long id of field "ABC" into tRef
hidetext tRef
...
showtext tRef
...
on hidetext pRef
put the text of pRef into the cHiddenText of pRef
set the text of pRef to empty
end hidetext
on showtext pRef
set the text of pRef to the cHiddenText of pRef
set the cHiddenText of pRef to empty
end showtext
-
- Livecode Opensource Backer
Re: Hiding text in a field
Another solution is to display a white rectangle in front of the text box.
There is one button on the stack and one field, the button contains the following script:
using templategraphic allows you to pop the graphic on screen without having to use lock screen. You can of course first create the graphic and reformat it, but then you will need to use lock screen to avoid the format changes to be visible to the user.
There is one button on the stack and one field, the button contains the following script:
Code: Select all
on mouseup
put the long id of field 1 into tRef
if the label of me is "show" then
showtext tRef
set the label of me to "hide"
else
hidetext tRef
set the label of me to "show"
end if
end mouseup
on hidetext pRef
-- Deciding of a name to give to the graphic
-- As we will delete it later, that's a good idea to add a prefix
-- to make sure we won't delete the wrong object
put the short name of pRef into tName
put ("hider" & tName) into tName
-- these 4 lines are to adjust the size of the rectangle
-- so to avoid to hide the vertical or horizontal scrollbars if they
-- exist
put 0 into tMarginH
if the hscrollbar of pRef is true then put the scrollbarWidth of pRef into tMarginH
put 0 into tMarginV
if the vscrollbar of pRef is true then put the scrollbarWidth of pRef into tMarginV
-- Setting the format and appearance of the rectangle
-- by defining the templateGraphic
set the style of the templateGraphic to rectangle
set the opaque of the templateGraphic to true
set the linesize of the templateGraphic to 0
set the backgroundcolor of the templateGraphic to white
set the width of the templateGraphic to (the width of pRef-tMarginH-2)
set the height of the templateGraphic to (the height of pRef -tMarginV- 2)
set the left of the templateGraphic to (the left of pRef+1)
set the top of the templateGraphic to (the top of pRef+1)
-- Drawing the graphic on screen
create graphic tName
end hidetext
on showtext pRef
put the short name of pRef into tName
put ("hider" & tName) into tName
if exists(graphic tName) then delete graphic tName
end showtext
-
- Livecode Opensource Backer
Re: Thank you
Excellent choicemlapl1 wrote:I prefer the first solution as it appears more elegant and more generalisable.

