How to create a fixed width InputEditField field

  • Is it possible to create a fixed width InputEditField field without using the Courrier font ?

    I am creating a question/answer form and I want to be able to have the answer region as a fixed width using the Arial font with a grey background. This has to work even if the keyboard is in insert mode. Currently, the closest to be able to do this is by using a Courrier font and pressing the insert key on the keyboard to disable the insert mode of the keyboard.


    For example, I want the region between the [...] characters to be of a fixed width with a grey background (I have put _ characters so that it displays properly but in reality, I want spaces):

    What is your first name: [ _____________________ ]


    Can you please tell me how to do this.


    Thanks,

    • Offizieller Beitrag

    Hi,

    It is not so easy since it requires the dynamic adaption of the width of the end marker.

    The OnEditFieldGetSize event has to be used.

    procedure TWPEdTest.DataEditEditFieldGetSize(Sender: TObject;
    const InspName: String; var EndmarkWidthTW: Integer;
    var Option: TWPEditFieldAlignOpt; CurrentTextWidthTW,
    CurrentTextCharCount: Integer; par: TParagraph; posinpar: Integer;
    FieldObject: TWPTextObj);
    begin
    EndmarkWidthTW := (50 * 100) - CurrentTextWidthTW;
    if EndmarkWidthTW<0 then EndmarkWidthTW := 0;
    end;

    Of course this only works if the insert points are visible.

    Julian

  • Your code works properly when the input edit field is initially created but when I start typing text into it, the end marker position gets positionned back to the end of the input text.

    Do you have another solution for this ?

    I think this feature is really important. It will allow the creation of electronic forms with fixed width input fields (just like paper forms). For example in Delphi, when I create a TEdit field I can set it's width and when I type text into the TEdit, the width doesn't get resized as you enter text.