Disabling Actions during a function then restoring.

General TRichView support forum. Please post your questions here
Post Reply
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Disabling Actions during a function then restoring.

Post by jgkoehn »

Greetings,
I have a lot of select then work with text in a big function and I would like to disable the updating of all the Font Combos, sizes etc. that are through RVAControlPanel.
I've tried ActionsEnabled := False before the function then ActionsEnabled := True after the function.
But it does not seem to do what I need. I still see the interface updating. Ideas.... ???
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Disabling Actions during a function then restoring.

Post by Sergey Tkachenko »

But assigning RVAControlPanel.ActionsEnabled = False really disables all RichViewActions.
However, if you call the function like this:

Code: Select all

  RVAControlPanel1.ActionsEnabled := False;
  Sleep(1000);
  RVAControlPanel1.ActionsEnabled := True;
you will not see that buttons are disabled for a second. It's because actions were not be able to update their states.
We can do it manually:

Code: Select all

  RVAControlPanel1.ActionsEnabled := False;
  for i := 0 to ActionList1.ActionCount - 1 do
    ActionList1.Actions[i].Update;
  Sleep(1000);
  RVAControlPanel1.ActionsEnabled := True;
Still no effect. It's because, while actions were updated, toolbars were not repainted.
So we repainting them:

Code: Select all

  RVAControlPanel1.ActionsEnabled := False;
  for i := 0 to ActionList1.ActionCount - 1 do
    ActionList1.Actions[i].Update;
  ToolBar1.Repaint;
  ToolBar2.Repaint;
  ToolBar3.Repaint;
  Sleep(1000);
  RVAControlPanel1.ActionsEnabled := True;
This code works. But not If this code is not called from a toolbar's button OnClick.
It works for all toolbars but not for a toolbar that contains a button that executes this code.
The problem can be solved by using PostMessage. Let me know if you need explanation how to do it.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: Disabling Actions during a function then restoring.

Post by jgkoehn »

Greetings Sergey,
Excellent thank you.
Do you have any recommendations to help speed up specifically GetSelection and SetSelection below.
>Select All Text
>Find a matching format Using GetSelection, SetSelection
>>>Once I have a selection of items I check the format of the items this goes quite fast
>Work with regex of this text


When I do SetSelection all icons are updated, font combo etc. I am not sure if this is slowing things down. Thus my previous question.
Is there a way to have a TRichViewEdit SetSelection only select items and do nothing else no icon update, no showing of what is select just the bare minimum for speed. Or should I use something else than SetSelection (I need to work with items and offs) is there something in RVData that would be better?
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: Disabling Actions during a function then restoring.

Post by jgkoehn »

Nevermind Sergey,
It was a problem with recopying over and over a large String. (I found my problem)
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Disabling Actions during a function then restoring.

Post by Sergey Tkachenko »

Just a note: ActionsEnabled disables all actions, but not font combo boxes. You need to assign Enabled properties of these combo boxes manually.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: Disabling Actions during a function then restoring.

Post by jgkoehn »

Thanks
Post Reply