Recent

Author Topic: Disable beep on arrow-down in Virtual TreeView on macOS M1, but keep navigation  (Read 1306 times)

Sanem

  • Full Member
  • ***
  • Posts: 179
Hello everyone, 

I'm using Lazarus on macOS M1 with the minimal Virtual TreeView test project. Whenever I press the arrow-down key to move to the next sibling, I hear a beep. I want to disable just that beep while keeping normal tree navigation intact.

I've tried: 
1. Setting `Message.Result := 1` in `WMKeyDown`, but it didn't stop the beep. 
2. Overriding the `OnKeyDown` event and setting `Key := 0` removes the beep and stops the tree from navigating.

Neither of these solutions worked for me on macOS M1 in the minimal Virtual TreeView test project. Does anyone know a method to cleanly remove the beep sound but keep the arrow key navigation? Any help would be much appreciated. 

Thank you!

Hansaplast

  • Hero Member
  • *****
  • Posts: 765
  • Tweaking4All.com
    • Tweaking4All
I do not have a good answer for you, but maybe you can try setting onBeep to nil? Not sure if that will do any good though.

Code: Pascal  [Select][+][-]
  1. OnBeep := nil;


Sanem

  • Full Member
  • ***
  • Posts: 179

Sanem

  • Full Member
  • ***
  • Posts: 179
I do not have a good answer for you, but maybe you can try setting onBeep to nil? Not sure if that will do any good though.

Code: Pascal  [Select][+][-]
  1. OnBeep := nil;

Thanks, I will try this as soon as I can, but I was searching for the root cause of the issue and how I can alter this behavior by changing or overriding some details about the virtual tree component. Any suggestions?
I tried 2 approaches but they did not solve the issue.

Sanem

  • Full Member
  • ***
  • Posts: 179
I resolved the issue by overriding the CNKeyDown event in TBaseVirtualTree using the approach below. This method retains the default navigation behavior and effectively prevents the beep sound when using the arrow keys on macOS.

Code: Pascal  [Select][+][-]
  1.  
  2.   protected
  3.     {$IFDEF DARWIN}
  4.     procedure CNKeyDown(var Message: TLMKeyDown); message CN_KEYDOWN;
  5.     {$ENDIF}
  6.                
  7. {$IFDEF DARWIN}
  8.  
  9. procedure TBaseVirtualTree.CNKeyDown(var Message: TLMKeyDown);
  10. begin
  11.   inherited;
  12.   WMKeyDown(Message);
  13.   Message.Result:=1;
  14. end;
  15.  
  16. {$ENDIF}
  17.  
  18.  



 

TinyPortal © 2005-2018