Recent

Author Topic: OSX Borderless TEDIT Anyone?  (Read 2869 times)

Josh

  • Hero Member
  • *****
  • Posts: 1274
OSX Borderless TEDIT Anyone?
« on: September 24, 2016, 07:58:28 am »
Hi

Does anyone know of a borderless TEDIT Component for OSX,
setting border to none does not remove the border as it does in windows.





The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Fungus

  • Sr. Member
  • ****
  • Posts: 353
Re: OSX Borderless TEDIT Anyone?
« Reply #1 on: September 24, 2016, 01:24:08 pm »
If you know how much space the borders take up, then you can add the TEdit control to a borderless TPanel and set TEdit.Top:= -BorderHeight; TEdit.Left:= -BorderWidth; HideBorderPanel.Width:= TEdit.Width - (2*BorderWidth);  HideBorderPanel.Height:= TEdit.Height - (2*BorderHeight). I know it's a hack, but it should work :-)

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: OSX Borderless TEDIT Anyone?
« Reply #2 on: September 24, 2016, 06:06:45 pm »
You can use Custom Drawn one and create a drawer (is how the TCDEdit is painted). For an example of a drawer see here:
https://github.com/bgrabitmap/bgracontrols/blob/master/bgracustomdrawn.pas

First install Custom Drawn package (comes with Lazarus).

Code: Pascal  [Select][+][-]
  1. TBGRADrawer = class(TCDDrawerCommon)

That is the class descendant you need to create (With a name of your choice), and here the Edit methods you need to override:

Code: Pascal  [Select][+][-]
  1. { Edit }
  2.     procedure DrawEditBackground(ADest: TCanvas; ADestPos: TPoint;
  3.       ASize: TSize; AState: TCDControlState; AStateEx: TCDEditStateEx); override;
  4.     procedure DrawEditFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
  5.       AState: TCDControlState; AStateEx: TCDEditStateEx); override;
  6.     procedure DrawCaret(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
  7.       AState: TCDControlState; AStateEx: TCDEditStateEx); override;
  8.     procedure DrawEdit(ADest: TCanvas; ASize: TSize; AState: TCDControlState;
  9.       AStateEx: TCDEditStateEx); override;

Finally do this:

Code: Pascal  [Select][+][-]
  1. initialization
  2.   RegisterDrawer(TBGRADrawer.Create, dsCommon);

Then you can drop a TCDEdit, include your unit with your drawer in the uses of the form unit. That's all, you have your Edit with custom style you made.

ps

  • Full Member
  • ***
  • Posts: 136
    • CSS
Re: OSX Borderless TEDIT Anyone?
« Reply #3 on: September 26, 2016, 02:15:46 pm »
Just use TMemo instead of TEdit. TMemo work"s without border.
Small simple CSS/box model implementation: https://github.com/pst2d/csscontrols/tree/dev

Josh

  • Hero Member
  • *****
  • Posts: 1274
Re: OSX Borderless TEDIT Anyone?
« Reply #4 on: September 26, 2016, 05:01:20 pm »
Hi Lainz,

Thanks for your answer; I will play around with custome drawn, as this may be a usefull approach to create my own custom controls that Renders Cross Platform.

Hi ps.
Thanks I will look into the Tmemo, I never thought of using a Tmemo probably because of multiline; but then this is not a problem as Memo Key Events will be changed to allow just what I need to Enter.
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

 

TinyPortal © 2005-2018