Make an edit control with faint instructional background

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #37660
    HeDiBo
    Participant

    I would like to make an edit control like this:

    [attachment=8529:Edit with hint empty.jpg] when text is not entered, but changes to this:

    [attachment=8530:Edit with hint filled.jpg] when text is being entered (if entering text is cancelled or totally backspaced, the control shifts back to its initial state)

    It is a familiar setup these days, primarily used in web forms.

    What steps/controls could I use to accomplish this?

    #57299
    Support
    Keymaster

    I'm agree with you, this feature is useful.

    I think, this is must be centrally controlled option, maybe from sSkinManager.Options

    What do you think?

    #57303
    HeDiBo
    Participant
    'Support' wrote:

    I'm agree with you, this feature is useful.

    I think, this is must be centrally controlled option, maybe from sSkinManager.Options

    What do you think?

    I would prefer a new component (TsHintedEdit). WIth settings in SkinManager, every TsEdit would exhibit this behavior. That may not be what you want, because in other parts of your project you may want to use normal hints. Remember a HintedEdit can only contain a very short hint. Such a HintedEdit may have a separate normal hint as well!

    Thanks for considering this.

    #57306
    Support
    Keymaster

    The TextHint property exists in the Delphi 2009 and newer, and supported by AphaSkins.

    Do you mean this property?

    I thought about another feature, when all edits changes an own looking if some value has been entered there.

    #57311
    HeDiBo
    Participant
    'Support' wrote:

    The TextHint property exists in the Delphi 2009 and newer, and supported by AphaSkins.

    Do you mean this property?

    I thought about another feature, when all edits changes an own looking if some value has been entered there.

    I'm an old Delphi 7 programmer. So, I never knew the property already existed. When I looked into it, I found that it is not used in the control that would most benefit from it: the TsDBEdit. That's because it is also missing in it's parent TDBEdit. Any idea why TextHint is a public property in TDBEdit i.s.o. a published property?

    Your idea of changing an edit's look when something is entered is nice a7.gif

    #57313
    HeDiBo
    Participant

    I looked further into the TextHint implementation of Delphi. And it's plain wrong. Because when the user shifts focus to a TEdit the hint disappears huh.gif

    They made this a deliberate “feature” because Windows does allow a visible hint when the edit has focus. But Delphi decided to ignore this possibility and remove the hint whenever the user shifts focus to the control a1.gif

    However they were gracious enough to make the flawed DoSetTextHint procedure virtual. That would allow for TsEdit to use a general sSkinManager.Options value to show the hint always.

    #57314
    HeDiBo
    Participant

    When I looked at your implementation of TextHint, I could not understand how the Hint would disappear when the TsEdit has focus.

    Then I realized that it was finally a problem in DoTextHint.

    I made an obvious modification to the TsEdit component by overriding the DoTextHint procedure and the hint text would show on an empty edit field even if it was focused, as expected.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.