Re: About layered commands


Cyrille
 

Hi Abdel

 

I have tested your example script in comparison with Instant Translate, adding an error in the help (H) script.

 

For instant translate:

  • Press NVDA+shift+T to activate layered commands
  • Press H to get help
  • An error occurs in the log. The layered command is exited but the exit sound is not heard.

 

With your example script:

  • Press control+F9 to activated layered commands
  • Press H for help
  • An error is logged but the layered command mode remains active
  • Press another unbound key command, e.g. A
  • Layered command mode is exited correctly

 

Actually, IMO the best solution would be an intermediate between these two ways to do, i.e. exit layered mode immediately but keep the exit sound anyway.

 

PS: regarding decorators, why did you remove them? Is it just because you did not need them anymore? Or another reason?

 

Cheers,

 

Cyrille

 

 

 

 

 

 

 

De : nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> De la part de Abdel
Envoyé : mercredi 1 septembre 2021 22:36
À : nvda-addons@nvda-addons.groups.io
Objet : Re: [nvda-addons] About layered commands

 

Hi dear Cyrille,

-Thank you so much.

You wrote:

The downside is that if an error occurs in a layered script, the layer is not exited and you need



I don't think so, I invite you to test.

This code provides an exit that helps avoid these situations as does decorator's finally block.

Look at lines 35 and 36 :

         # We call the finish method in all cases.
         self.finish ()
 

 


Kind regards,
Abdel.

Le 01/09/2021 à 22:05, Cyrille via groups.io a écrit :

Hello my friend Abdel

Nice to find you again even on English mailing lists! Welcome back!

I am wondering why you want to remove the decorators. IMO they are a nice way to write Python code; think to the widely used @script decorator.
In any case, a decorator is never absolutely necessary. Indeed, in Python it is only another to way to call a functions that takes a function as parameter and that returns a function. I.e.:

@myDecorator
def foo()
    pass

is the same as:

def foo():
    pass
foo = myDecorator(foo)

Regarding your code, you do not have only removed the decorators. You have also simplified the usual layered key management code.
The downside is that if an error occurs in a layered script, the layer is not exited and you need to press another key to exit it.

Cheers,

Cyrille






 

De : "Abdel"
A : nvda-addons@groups.io
Envoyé: mercredi 1 Septembre 2021 20:03
Objet : [nvda-addons] About layered commands
 

Hi everyone,

First of all, I wanted to apologize for this long silence, I was rather
busy lately.

Some time ago, I had used an implementation, in Clock add-on, which uses
layered commands without using a decorator.

I think it is important to clarify that the decorator is not really
essential to achieve this.

You will find as attachment, a small implementation, which has 2 scripts
that can be executed in layers mode.

You can test if you wish in the "Scratchpad" directory.

You will just have to activate the use of the developer's scratchpad in
the advanced settings.

The script for executing layer mode can be started with "Control + F9".

In layer mode, you can use the "H" for help or "M" to hear a simple message.

What are your thoughts?

Kind regards,
Abdel.






 

Join nvda-addons@nvda-addons.groups.io to automatically receive all group messages.