Menu

Handling resizing DPFTextView with keyboard

justapps
2013-09-09
2013-09-10
  • justapps

    justapps - 2013-09-09

    I start a new mobile project. I drop a DPFUIScrollView on the form and set the alignment to alClient. Then I drop a DPFTextView on the scrollview and set the alignment to alClient. How do I handle making the textview resizing when the keyboard is present? I would like for it to resize when the screen is rotated as well. I realize I may not need a scrollview in this case since it is just one control.

    Thanks!
    Brent

     

    Last edit: justapps 2013-09-09
  • Fenistil

    Fenistil - 2013-09-09

    Hi!

    You can find a sample in the ScrollViewTextField Demo. Otherwise, on your main form, create the VirtualKeyboardShown and VirtualKeyboardHidden events. In the VirtualKeyboardShown you will get the area above the keyboard in the Bounds const. Set your TextView's align to None and set its size to the Bounds. In the Hidden event, set it back to alClient.

    I hope it helps.

    Greetings

     
  • justapps

    justapps - 2013-09-09

    Thanks for pointing me in the right direction. The demo has some missing arguments.

    This seems to work:

    private
      FKBBounds : TRectF;
    ...
    procedure TForm1.FormVirtualKeyboardHidden(Sender: TObject;
      KeyboardVisible: Boolean; const Bounds: TRect);
    begin
      FKBBounds.Create(0, 0, 0, 0); // seems to work ok without this line
      TextView1.Align := TAlignLayout.alClient;
    end;
    
    procedure TForm1.FormVirtualKeyboardShown(Sender: TObject; KeyboardVisible: Boolean; const Bounds: TRect);
    begin
      TextView1.Align := TAlignLayout.alNone;
      FKBBounds := TRectF.Create(Bounds);
      TextView1.SetBounds(1,1,FKBBounds.Width, Height - FKBBounds.Height);
    end;
    
     

    Last edit: justapps 2013-09-10
  • Fenistil

    Fenistil - 2013-09-09

    I'm glad to help.

    The Demo was made for a prior version of the ScrollView and hasn't been updated.

    Just a hint: You can find how to post source code formatted in the Welcome topic. Please use it in the future. Thanks :)

     
  • justapps

    justapps - 2013-09-10

    Ok, thanks. I went back to test that. Now it's formatted correctly :)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.