Forum (FR)

[SOLVED] [CTRL]-S t...
 
Notifications
Retirer tout

[SOLVED] [CTRL]-S to save in form window broken ?

7 Posts
4 Utilisateurs
0 Reactions
10.8 {numéro}K Vu
 DPo
(@dpo)
Posts: 11
Active Member
Début du sujet
 
[#2033]

Hi,
It seems that the behavior of [CTRL]-S is broken in the form frame (general for all the objects : project, activity, ...).
I used to save directly with a [ctrl]-S directly when in any input object of the form. Now a window of firefox open to save the html page :huh: .

Although, it seems, that when clicking / focusing into the menu of the frame (where the buttons stand), [ctrl]-S has the right behavior and save the form.

Version Projeqtor : 4.4.2
Firefox : 32.0.3


 
Posté : 7 Oct PM 19:1010
(@babynus)
Posts: 14952
Membre Admin
 

Hi,

This seems to be a V4.4 regression on FireFox.
I checked : works fine on Chrome & IE, works fine on Firefox with V4.3.

Ticket #1544 recorded


 
Posté : 7 Oct PM 19:1010
 Dan
(@caccia)
Posts: 340
Contributor
 

Hi all,

Noticed the same - only on Firefox it seems. One of our developers had a look and found a solution, so hopefully this can help others:

1) in main.php, around line 170:
replace:

      var onKeyPressFunc = function(event) {
        if(event.ctrlKey && event.keyChar == 's'){
          event.preventDefault();
        	globalSave();
        } else if (event.keyCode==dojo.keys.F1 && ! event.keyChar) {
        	event.preventDefault();
        	showHelp();
        }  
      };

with :

     var onKeyPressFunc = document.addEventListener("keydown", function(e) {
        if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) { // CTRL + S
          e.preventDefault();
          stopDef();
          globalSave();
        } else if (e.keyCode == 112) { // On F1
          e.preventDefault();
          stopDef();
          showHelp();
        }
      }, false);

2) In projeqtor.js, add function:

// Prevent default && "unfocus" all inputs

function stopDef(e) {
  var inputs, index;

  inputs = document.getElementsByTagName('input');
  for (index = 0; index < inputs.length; ++index) {
      inputs[index].blur(); 
  }

  if (e && e.preventDefault)
    e.preventDefault();
  else if (window.event && window.event.returnValue)
    window.eventReturnValue = false;
};

 
Posté : 7 Oct PM 19:1010
(@babynus)
Posts: 14952
Membre Admin
 

Hi,

Thanks caccia for the workaround.
It confirms my analysis : on FF, the onkeypress is not triggered when focus is in an input field.
So the idea to add listener on the keydown that blurs the field when needed fixes the issue.
But this can lead to loose of focus. Not important if save is correct (frame is refreshed) but if error occurs, focus is lost.

By the way, it was working on V4.3, so I tried to replace dojo version from V10.0 (used un V4.4) to V9.3 (used on V4.4) : and this fixes the issue.
So simple fix is to retrieve /external/dojo /external/dijit and /external/dojox from V4.3.x and overwrite it on V4.4.

NB : I tested Dojo V10.1, issue still exists.


 
Posté : 7 Oct PM 20:1010
(@babynus)
Posts: 14952
Membre Admin
 

For information I openned an issue in Dojo Trac database : #18303
https://bugs.dojotoolkit.org/ticket/18303


 
Posté : 7 Oct PM 22:1010
(@jarekd)
Posts: 3
New Member
 

There seems to be another bug. Occurs in 4.4.2 using Chrome. Not sure but might be related to Dojo as well.

Pressing Right Alt + 's' invokes ProjeQtOr save function despite the condition in main.php checking for CTRL key.

I use the Alt+'s' to enter national character so it is confusing. Temporarily removed Ctrl+S shortcut code from main.php.

ProjeQtOr 4.4.2 Chrome 38.0.2125.101 m


 
Posté : 14 Oct PM 19:1010
(@babynus)
Posts: 14952
Membre Admin
 

Hi,

Strange, but AltGr sets event.ctrlKey ti true.
And it is nit browser dependant...

Solution : in /view/main.php, replace

var onKeyPressFunc = function(event) {
        if(event.ctrlKey && event.keyChar == 's'){

with

var onKeyPressFunc = function(event) {
        if(event.ctrlKey && ! event.altKey && event.keyChar == 's'){

Fix will be included in V4.5.0


 
Posté : 15 Oct PM 18:1010
Share:
Retour en haut