PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2025 → Raccourcis clavier
Raccourcis clavier
Iniciado por Julien V, 06,jul. 2020 10:56 - 1 respuesta
Miembro registrado
134 mensajes
Publicado el 06,julio 2020 - 10:56
Bonjour,

Ci dessous un petit code pour afficher la liste des raccourcis clavier d'une fenêtre.

Merci à ceux qui ont répondu au post https://forum.pcsoft.fr/fr-FR/pcsoft.fr.windev/240929-raccourcis-clavier/read.awp

Soit :
- constantesTouches un tableau associatif de chaines reprenant les constantes de KeyConst.wl
ex.
constantesTouches[ 0x0D ] = "Entrée" // "VK_RETURN"

- gproc_traduire_toucheRaccourci qui traduit le numéro de la propriété ..ToucheRaccourci en chaine
- gproc_afficher_touchesRaccourcis qui renvoie une info listant tous les raccourcis

Procedure gproc_traduire_toucheRaccourci( _toucheRaccourci est un entier, _libelle est une chaîne = "" )

i, iMax est un entier
toucheRaccourci, valeurSansPoidsFaible est un entier
libelle, toucheControle, toucheCaractere, toucheConstante est une chaîne
combinaison est un tableau de 0 chaîne
avecEtCommercial est un booléen

toucheRaccourci = _toucheRaccourci
libelle = _libelle

// Après '&' du libellé
SI toucheRaccourci = 65535 _ET_ libelle <> "" ALORS

iMax = Taille( libelle )
POUR i = 1 À iMax

SI libelle[ i ] = "&" ALORS
avecEtCommercial = PAS avecEtCommercial
SINON SI avecEtCommercial ALORS
TableauAjoute( combinaison, "Alt + " + libelle[ i ] )
SORTIR
FIN // SI libelle[ i ] = "&" ALORS

FIN // POUR i = 1 À iMax

SINON

valeurSansPoidsFaible = Val( toucheRaccourci - PoidsFaible( toucheRaccourci ) )

SELON valeurSansPoidsFaible
CAS trAlt : toucheControle = "Alt"
CAS trControl : toucheControle = "Ctrl"
CAS trShift : toucheControle = "Maj"
AUTRE CAS : toucheControle = ""
FIN // SELON valeurSansPoidsFaible

SI toucheControle <> "" ALORS TableauAjoute( combinaison, toucheControle )

SI PoidsFaible( toucheRaccourci ) >= 0 ET PoidsFaible( toucheRaccourci ) <= 255 ALORS

toucheConstante = COL_Outils.constantesTouches[ PoidsFaible( toucheRaccourci ) ]
SI toucheConstante <> "" ALORS

TableauAjoute( combinaison, toucheConstante )

SINON

toucheCaractere = Caract( PoidsFaible( toucheRaccourci ) )
SI toucheCaractere <> "" ALORS
TableauAjoute( combinaison, toucheCaractere )
FIN // SI toucheCaractere <> "" ALORS

FIN // SI toucheConstante <> "" ALORS

FIN // SI PoidsFaible( toucheRaccourci ) >= 0 ET PoidsFaible( toucheRaccourci ) <= 255 ALORS

FIN // SI toucheRaccourci = 65535 ALORS

RENVOYER TableauVersChaîne( combinaison, " + " )

Procedure gproc_afficher_touchesRaccourcis( _fenetreInterne est un Champ )

raccourcis est un tableau de chaîne

iproc_enumereChamp( _fenetreInterne )

SI TableauOccurrence( raccourcis ) > 0 ALORS
TitreSuivant( "Raccourcis clavier" )
Info( TableauVersChaîne( raccourcis, CR ) )
FIN // SI TableauOccurrence( raccourcis ) > 0 ALORS

PROCEDURE INTERNE iproc_enumereChamp( LOCAL _parent est un Champ )

i est un entier
champ, libelle, raccourci est une chaîne
parents est un tableau de Champ
c est un Champ

// Boucle sur les champs
i = 1
champ = EnumèreChamp( _parent, i )
TANTQUE champ <> ""

c <- EnumèreChamp( _parent, i )

SI c..Type DANS ( typDisposition, typFen, typGrp, typFenêtreInterne, typModèleDeChamp, typOnglet, typRegroupementRuban, typRuban, typSuperChamp, typTiroir, typVoletOnglet, typZoneMultiligne, typZoneRépétée ) ALORS

TableauAjoute( parents, c )

SINON

SI c..ToucheRaccourci <> 0 ALORS

raccourci = gproc_traduire_toucheRaccourci( c..ToucheRaccourci, c..Libellé )
SI raccourci <> "" ALORS

SELON c..Type

CAS typBouton : libelle = "Bouton"
CAS typComboAVS, typComboSNS, typListe, typListeImage : libelle = "Liste"
CAS typInterr, typInterrupteurABascule : libelle = "Interrupteur"
CAS typSelect : libelle = "Sélecteur"
AUTRE CAS : libelle = "Champ"

FIN // SELON c..Type

SI c..Libellé <> "" ALORS
libelle += [ " " ] + c..Libellé
SINON
libelle += [ " " ] + champ
FIN // SI c..Libellé <> "" ALORS

TableauAjoute( raccourcis, libelle + " : " + raccourci )

FIN // SI raccourci <> "" ALORS

FIN // SI champs[ champ ]..ToucheRaccourci <> 0 ALORS

FIN // SI champs[ champ ]..Type DANS ( typDisposition, typFen, typGrp, typFenêtreInterne, typModèleDeChamp, typOnglet, typRegroupementRuban, typRuban, typSuperChamp, typTiroir, typVoletOnglet, typZoneMultiligne, typZoneRépétée ) ALORS

i++
champ = EnumèreChamp( _parent, i )
FIN // TANTQUE champ <> ""

POUR TOUT parent de parents
iproc_enumereChamp( parent )
FIN // POUR TOUT parent de parents

FIN // PROCÉDURE INTERNE iproc_enumereChamp( LOCAL _parent est une chaîne )


Et le résultat :






Miembro registrado
310 mensajes
Publicado el 06,julio 2020 - 11:40
Bonjour,
Merci pour le partage.
Toujours appréciable d'avoir un retour sur l'usage fait des contributions.

Bon dev !