Code Monkey home page Code Monkey logo

Comments (20)

Alexey-T avatar Alexey-T commented on August 24, 2024

it is valid comment. i suggest to add "if not csLoading in ComponentState" or smth. can you try to add it?

from atflatcontrols.

aducom avatar aducom commented on August 24, 2024

I assume that you mean to add it to your component code? Will try. Been ages I've been working creating components and never done it for Lazarus, but I'll try.

from atflatcontrols.

Alexey-T avatar Alexey-T commented on August 24, 2024

Yes, to my code

from atflatcontrols.

aducom avatar aducom commented on August 24, 2024

I am working on it, but ended up in a stack error. Reverted back to the original, but problem persists on attabs.pas:1137
Will look into this further some other moment, I fear that I have to reinstall Laz.

from atflatcontrols.

Alexey-T avatar Alexey-T commented on August 24, 2024

I guess it’s ok to add this /If/ above the call of FOnTabChange

from atflatcontrols.

aducom avatar aducom commented on August 24, 2024

I fixed it. Code below

   procedure TATTabs.SetTabIndex(AIndex: integer);
   //note: check "if AIndex=FTabIndex" must not be here, must be in outer funcs.
   //Sometimes SetTabIndex(TabIndex) is needed, eg in DeleteTab().
   var
     CanChange: boolean;
     doClickEvent : boolean;
   begin
     doClickEvent :=  (aIndex <> FTabIndex);      // Only generate onClickEvent when the tab changes
                                                  // This prevents a potential endless loop if the event
                                                  // is triggered in software (aducom)
     if csLoading in ComponentState then
       FTabIndexLoaded:= AIndex;

     if IsIndexOk(AIndex) then
     begin
       CanChange:= true;
       if Assigned(FOnTabChangeQuery) then
       begin
         FOnTabChangeQuery(Self, AIndex, CanChange);
         if not CanChange then Exit;
       end;

       FTabIndex:= AIndex;

       MakeVisible(AIndex);
       Invalidate;
       if Assigned(FOnTabClick) then
          if not(csLoading in ComponentState) then    // avoid click event while component is being created (aducom)
             if doClickEvent then
                FOnTabClick(Self);
     end;
   end; 

from atflatcontrols.

Alexey-T avatar Alexey-T commented on August 24, 2024

Use these fence chars, pls. edited the post.

```

from atflatcontrols.

Alexey-T avatar Alexey-T commented on August 24, 2024

Pls see my comment in code
//note: check "if AIndex=FTabIndex" must not be here, must be in outer funcs.
//Sometimes SetTabIndex(TabIndex) is needed, eg in DeleteTab().

from atflatcontrols.

aducom avatar aducom commented on August 24, 2024

I know, but this only influences the onclick. You will get infinite loops as I had one if you don't, If you think that it should trigger on deleting tab I can modify it further.
It is not logical to trigger if a tab is being deleted. Orignal flow is not influenced.

Let me explain it a bit better. If you change a tab then the event is triggered. If this trigger is caused by some program code it will trigger also. It makes no sence to trigger if the tab is not being changed. Of course you can do that from the outside, but if you don't (and it's not so obvious to do) then you end up with a stack error and that will be hard to find. I think you should do it in the component. If you delete a tab, then it is not logical to trigger an onclick because the deleted tab is not present any more.

from atflatcontrols.

Alexey-T avatar Alexey-T commented on August 24, 2024

okay. made this change, pls check it.

from atflatcontrols.

aducom avatar aducom commented on August 24, 2024

Confirmed. Thnx.

from atflatcontrols.

Alexey-T avatar Alexey-T commented on August 24, 2024

partially reverted, sorry- it gave problems in CudaText- initial tab was not shown+ clicking tab title didn't focus the tab.

from atflatcontrols.

aducom avatar aducom commented on August 24, 2024

I'm back to my stack error. Well, for now, I'll work with my own patch. Am not using Cudatext so can't judge implications. But it's good that the initialization issue if fixed. I don't have issues showing the initial tab. Focus issue is an interesting one though. (FTabIndex=-1 in the constructor will trigger initial change)

from atflatcontrols.

aducom avatar aducom commented on August 24, 2024

What do you think of adding an event ontabchanged? That will only fire if oldtab != newtab, made an implementation that I will test next week. Same for property tabvisible (ttabsheet compatibility)

from atflatcontrols.

Alexey-T avatar Alexey-T commented on August 24, 2024

Maybe show ur implementation, is it small code

from atflatcontrols.

aducom avatar aducom commented on August 24, 2024

Well, the onchange is a few lines of code and works well. The tabvisible should be similar, but I'm still strugling with the application flow, no matter what value I give the property, the status is always false. Within design mode it works well. But I'll get to it.

from atflatcontrols.

aducom avatar aducom commented on August 24, 2024

Ok, I have added the ontabchanged event and tested it. Should work ok with your other components. I also added the tabvisible property and two routines ShowTab(index) and HideTab(index). The function takes care of the tabindex to avoid issues with bound notebookpages if any. The issue is that I don't want to publish the full text here, unless you want me to. I have a small sample too showing the features. I can make a downloadable zip and publish for you. Let me know.

from atflatcontrols.

Alexey-T avatar Alexey-T commented on August 24, 2024

you can make a pull-request on github. in ATFlatCon repo, find file attabs.pas on site, then press EDIT button to edit it, paste your file.

check the changes in pull-req page.

from atflatcontrols.

Alexey-T avatar Alexey-T commented on August 24, 2024

Thanks, I have fixed your code a little.

from atflatcontrols.

aducom avatar aducom commented on August 24, 2024

Thanks, I have fixed your code a little.

Yes, seen that, but logical choice ;-)

from atflatcontrols.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.