Change the "download" keyboard shortcut (Ctrl+S) handling, in GENERIC/CHROME builds, to utilize the EventBus (issue 11657)
				
					
				
			This improves the consistency of the "download" handling, in the default viewer, such that the `Toolbar`/`SecondaryToolbar` buttons *and* the keyboard shortcut are now handled in the same way (using the `EventBus`). Given that the "download" keyboard shortcut handling is limited to GENERIC/CHROME builds and that the issue does raise a valid point about only being able to observe *some* downloads, these changes seem acceptable in this particular case. Finally the pre-processor condition is adjusted to *explicitly*, rather than implicitly, list the affected build targets. *Please note:* This patch should NOT be construed as carte blanche to simply convert all of the code in `webViewerKeyDown`, or elsewhere, to make use of the `EventBus` instead of direct function calls. Any further changes, along the lines in this patch, would need to be evaluated on a case-by-case basis to determine if they are actually wanted, given that many/most existing cases in `webViewerKeyDown` should already be *indirectly* observable through the `EventBus` instance.
This commit is contained in:
		
							parent
							
								
									49f59eb627
								
							
						
					
					
						commit
						a8a22283c3
					
				@ -2571,12 +2571,14 @@ function webViewerKeyDown(evt) {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
 | 
			
		||||
  if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC || CHROME")) {
 | 
			
		||||
    const { eventBus } = PDFViewerApplication;
 | 
			
		||||
 | 
			
		||||
    // CTRL or META without shift
 | 
			
		||||
    if (cmd === 1 || cmd === 8) {
 | 
			
		||||
      switch (evt.keyCode) {
 | 
			
		||||
        case 83: // s
 | 
			
		||||
          PDFViewerApplication.download();
 | 
			
		||||
          eventBus.dispatch("download", { source: window });
 | 
			
		||||
          handled = true;
 | 
			
		||||
          break;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user