Recent

Author Topic: TabControl - need some basic explanations  (Read 4398 times)

BubikolRamios

  • Sr. Member
  • ****
  • Posts: 267
TabControl - need some basic explanations
« on: February 01, 2015, 08:09:03 pm »
folowing this:
http://docwiki.embarcadero.com/CodeExamples/XE7/en/TabControlChange_%28Delphi%29

Quote
place a tab control on a form and add a SynEdit control that fits into its client area

OK done, don't want to load files as in exampa for now, just want new SynEdit for each tab

Quote
procedure TForm1.Button3Click(Sender: TObject);
...
TabControl1.Tabs.Add('foo');   

OK tabs are appearingh but synedit is al the time the same, one would expect new  empty syn edit as new tab is added with click,
and seprate synedit for each tab, right ?

Seems I can't find anything on google (Ok LazEdit has that funcionality  but don't want to go looking thru entire code).

give me some basic tips (-:

lazarus 3.2-fpc-3.2.2-win32/win64

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: TabControl - need some basic explanations
« Reply #1 on: February 01, 2015, 08:29:49 pm »
Quote
OK tabs are appearingh but synedit is al the time the same, one would expect new  empty syn edit as new tab is added with click,
and seprate synedit for each tab, right ?

This is how TPageControl works. Each TabSheet is unique area for component.

TTabControl, on the other hand, share the same area (with TSynEdit, in your case). It is expected that you will use OnChange event of the TTabControl, where you fill the synedit with specific content whenever user changes tab.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

BubikolRamios

  • Sr. Member
  • ****
  • Posts: 267
Re: TabControl - need some basic explanations
« Reply #2 on: February 01, 2015, 08:45:18 pm »
Seems logical in case of simultaneusly opening tab & loading file contence.
But if I change contence od synedit with typing , do I have to save conence of syedit to appropriate file (or into memory) on each tab change ?
lazarus 3.2-fpc-3.2.2-win32/win64

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9857
  • Debugger - SynEdit - and more
    • wiki
Re: TabControl - need some basic explanations
« Reply #3 on: February 01, 2015, 09:02:01 pm »
You can have many TSynEdit with a TTabControl, but you must manage which one is visible (Visible := True/False; BringToFront; ...)

Much easier to use a TPageControl. Add a SynEdit into each Page, and done.

SourceEditor in the IDE uses a PageControl. (Well an inherited one, for dragging of tabs)

BubikolRamios

  • Sr. Member
  • ****
  • Posts: 267
Re: TabControl - need some basic explanations
« Reply #4 on: February 01, 2015, 09:12:20 pm »
Ok, thanks.

Read somewhere TTabControl is for cases where you have same controls on each tab, was sticked to that ...
lazarus 3.2-fpc-3.2.2-win32/win64

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9857
  • Debugger - SynEdit - and more
    • wiki
Re: TabControl - need some basic explanations
« Reply #5 on: February 01, 2015, 09:16:45 pm »
Ok, thanks.

Read somewhere TTabControl is for cases where you have same controls on each tab, was sticked to that ...

Thats right. "Same" = "SynEdit with same content"

Therefore you need to manage the content yourself. However if you do that you loose undo info. So not good.

 

TinyPortal © 2005-2018