Page 1 of 1

Disabling Actions during a function then restoring.

Posted: Thu Jun 09, 2022 11:36 pm
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.... ???

Re: Disabling Actions during a function then restoring.

Posted: Fri Jun 10, 2022 9:45 am
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.

Re: Disabling Actions during a function then restoring.

Posted: Fri Jun 10, 2022 5:04 pm
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?

Re: Disabling Actions during a function then restoring.

Posted: Fri Jun 10, 2022 6:01 pm
by jgkoehn
Nevermind Sergey,
It was a problem with recopying over and over a large String. (I found my problem)

Re: Disabling Actions during a function then restoring.

Posted: Fri Jun 10, 2022 6:26 pm
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.

Re: Disabling Actions during a function then restoring.

Posted: Sat Jun 11, 2022 10:18 pm
by jgkoehn
Thanks