Recent

Author Topic: Beeping sound when cursor pressed on TLazVirtualStringTree (The plot thickens..)  (Read 703 times)

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 416
* Mac Mini M1 (silicon)
* macOS 14.6.1
* Lazarus 3.4
* FPC 3.2.2

I'm using, for the first time, a TLazVirtualTreeView in my app. I've also opened up the "virtualtreeview/vst_minimal" example app to get to grips with the component. In both the example and in my app, a cursor down or a cursor up produces a strange beep on every key press.

Can anyone tell me why it does this, and, more importantly, how to stop it?  ;)
« Last Edit: September 28, 2024, 05:21:31 pm by carl_caulkett »
"It builds... ship it!"

Thaddy

  • Hero Member
  • *****
  • Posts: 15646
  • Censorship about opinions does not belong here.
Re: Beeping sound when cursor down or up is pressed on TLazVirtualTreeView
« Reply #1 on: September 18, 2024, 07:00:05 pm »
To stop it, turn down the volume.
It is not caused by fpc code, but it is an OS "feature" and such things should really not be "fixed".I supose you are on Windows? You give us very little information.
If I smell bad code it usually is bad code and that includes my own code.

TRon

  • Hero Member
  • *****
  • Posts: 3236
Re: Beeping sound when cursor down or up is pressed on TLazVirtualTreeView
« Reply #2 on: September 18, 2024, 08:35:56 pm »
The funny thing for me is that I am running a particular linux distro on several different machines.  Only one of them seem to have the DE system sounds enabled by default while on the other machines it does not. Might perhaps depend on what packages are installed (different hardware) but I found it interesting inconsistent behaviour nonetheless (I probably should ask the maintainers about that).
All software is open source (as long as you can read assembler)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10296
  • Debugger - SynEdit - and more
    • wiki
Re: Beeping sound when cursor down or up is pressed on TLazVirtualTreeView
« Reply #3 on: September 18, 2024, 08:39:37 pm »
Well, at least your OS, and Desktop manager....

I don't get sound from the virtual tree view.

If you use Lazarus 3.x open the watches window, add a few watches and go up/down with the keys => I don't get any sound (not on Windows, not on Fedora 37 (Gnome))

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 416
Re: Beeping sound when cursor down or up is pressed on TLazVirtualTreeView
« Reply #4 on: September 18, 2024, 09:03:33 pm »
To stop it, turn down the volume.
It is not caused by fpc code, but it is an OS "feature" and such things should really not be "fixed".I supose you are on Windows? You give us very little information.

Sorry, I forgot to post my system specs. Please see the original (amended) post,
but to save your, no doubt, valuable time, I'll mention it again...
* Mac Mini M1 (silicon)
* macOS 14.6.1
* Lazarus 3.4
* FPC 3.2.2

As for your answer, did you mean that seriously?

I take it from the tone of your comment about the OS that you are not on Windows, either. I despise Windows as a product but I try to restrain myself from talking down to its users!

My form currently has a TListView which does not exhibit this "beeping" while the TLazVirtualTreeView component beeps like crazy in both my app and the "vst_minimal" example app. If it is an OS "feature" it must be a remarkably selective feature, or maybe there is something that only manifests itself in macOS, presumably due to insufficient testing.

"It builds... ship it!"

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 416
Re: Beeping sound when cursor down or up is pressed on TLazVirtualTreeView
« Reply #5 on: September 18, 2024, 09:07:30 pm »
@TRon and @Martin_fr,

Thanks for your constructive replies  ;)

@Martin_fr, yes, I'll do what you suggest to see if I can, at least pin-point the code that is causing the beep.
"It builds... ship it!"

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 416
Re: Beeping sound when cursor down or up is pressed on TLazVirtualTreeView
« Reply #6 on: September 18, 2024, 09:11:58 pm »
You give us very little information.

Did the fact that this was posted in the "macOS / Mac OS X" channel not offer just the slightest clue as to what my system was?
"It builds... ship it!"

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10296
  • Debugger - SynEdit - and more
    • wiki
Re: Beeping sound when cursor down or up is pressed on TLazVirtualTreeView
« Reply #7 on: September 18, 2024, 09:17:24 pm »
I don't think (but also don't know the opposite) that the sound is deliberately caused by the v-tree view.

It could be that maybe the message for keydown/keypress is not probably acknowledged?

Also maybe looking at the original vtv git commit log, and see if anything mentions something.

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 416
Re: Beeping sound when cursor down or up is pressed on TLazVirtualTreeView
« Reply #8 on: September 18, 2024, 10:48:07 pm »
I don't think (but also don't know the opposite) that the sound is deliberately caused by the v-tree view.

I'm sure it isn't deliberate. Believe me if there was no way to avoid it, I'm sure it would soon be discarded!

It could be that maybe the message for keydown/keypress is not probably acknowledged?

Yeah! That's what I was thinking. I've just done a search for "debugging into fpc source" and it's led me to this github repo https://github.com/LongDirtyAnimAlf/Reiniero-fpcup, but unfortunately the executable for the "fpclazup-aarch64-darwin"  won't run on my M1 Mac. In fact it doesn't even download as anything recognisable by my system... see attachment 1.

I tried adding ".zip" and ".app" extensions to see if I could get the file to open but no dice!

I also tried to build both the "fpcup.lpi" and the "fpclazup.lpi" project from source, but in both cases I'm getting the error...
Code: Text  [Select][+][-]
  1. Compiler "/usr/local/bin/fpc" does not support target powerpc64-darwin
  2.  

Also maybe looking at the original vtv git commit log, and see if anything mentions something.

It's getting late so I'm going to leave this till tomorrow morning 😉
"It builds... ship it!"

TRon

  • Hero Member
  • *****
  • Posts: 3236
Re: Beeping sound when cursor down or up is pressed on TLazVirtualTreeView
« Reply #9 on: September 18, 2024, 10:51:22 pm »
Well, at least your OS, and Desktop manager....
true

Quote
I don't get sound from the virtual tree view.
Interesting. I'll give it a spin on that particular machine to see if I am able to repeat that.

Quote
It could be that maybe the message for keydown/keypress is not probably acknowledged?
I was thinking perhaps it is because the implementation does something additional even though my initial thought is it is related to my desktop settings (because overall I get beeps even in non Lazarus desktop applications while not being the case on/for the other machines).

It is imho the more interesting because of TS' platform. that should be as steady as a rock (e.g. no behavioural changes for each and every update).
« Last Edit: September 18, 2024, 10:53:20 pm by TRon »
All software is open source (as long as you can read assembler)

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 416
Re: Beeping sound when cursor down or up is pressed on TLazVirtualTreeView
« Reply #10 on: September 19, 2024, 12:20:27 am »
I've had a breakthrough that suggests that the solution might be reached by code change. Handling the OnKeyDown event like this gets rid of the beep...
Code: Pascal  [Select][+][-]
  1. procedure TMainView.PresetTreeKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  2. begin
  3.   case Key of
  4.     VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT:
  5.       begin
  6.         if Key = VK_DOWN then
  7.           PresetTree.FocusedNode := PresetTree.GetNext(PresetTree.FocusedNode);
  8.         if Key = VK_UP then
  9.           PresetTree.FocusedNode := PresetTree.GetPrevious(PresetTree.FocusedNode);
  10.         Key := 0; // Prevent default handling and beep
  11.       end;
  12.   end;
  13. end;
  14.  

This moves the selection box up and down but it does not move the highlight colour. But at least it doesn't beep  :D
Gives me something to work on!

The next step will be to build a TLazVirtualStringTree descendent with all of this built into an overridden KeyDown method ;)
« Last Edit: September 19, 2024, 12:23:38 am by carl_caulkett »
"It builds... ship it!"

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10296
  • Debugger - SynEdit - and more
    • wiki
Re: Beeping sound when cursor down or up is pressed on TLazVirtualTreeView
« Reply #11 on: September 19, 2024, 10:18:04 am »
The Key:=0 makes sense.

VTV is a custom control. The OS does not know anything about it. The OS can send the key there, but if the control does not take the key, the OS does not know what to do with it.

Well, maybe a bit more complex... Needs testing. If a Tab is sent there, and not "eaten up" then the OS would know that that key still is meant for something else (change to another focusable control / actually the WS or LCL would get that).

And so there may be other keys. So only keys that were handled (translated into an action) should (and must) be set to zero.

That however means, that most likely if you press "A" (and "A" does nothing) then you do get a beep. And that is likely how your OS works, if you press a key and it can not be handled then it beeps?


carl_caulkett

  • Sr. Member
  • ****
  • Posts: 416
Re: Beeping sound when cursor down or up is pressed on TLazVirtualTreeView
« Reply #12 on: September 20, 2024, 06:20:10 pm »
I've solved the issue by giving up on the TLazVirtualTreeView and resorting to the good old TTreeView. I don't need to edit any of the data in columns, so I can probably get away with some crafty owner draw stuff to simulate  columns...
« Last Edit: September 28, 2024, 05:40:04 pm by carl_caulkett »
"It builds... ship it!"

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 416
Re: Beeping sound when cursor down or up is pressed on TLazVirtualStringTree
« Reply #13 on: September 28, 2024, 05:06:10 pm »
Firstly, my apologies, I have been referring to TVirtualTreeView when I should have been talking about the TLazVirtualStringTree! I'm not the first who has been confused by the name change, and I bet I won't be the last  ;)

I've seen the thread where the name change was explained, so no need to explain it again https://forum.lazarus.freepascal.org/index.php/topic,58268.msg434082.html#msg434082

I decided to go back to using the TLazVirtualStringTree. For the first few iterations of the project, I used a TPageControl with my existing TTreeView on one TTabSheet and my reinstated TLazVirtualStringTree on the other TTabSheet. I was encouraged by the fact that no beeping occurred this time. I started to remove the old TTreeView and related code. Still no beeping! Eventually I took the plunge and relocated the TLazVirtualStringTree to the main form and got rid of the TPageControl. The beeping RETURNED  :o

I'd been keeping backups at every stage of this process and went back to the last version that didn't beep, so no harm was done. Eventually I ended up having to keep the TPageControl with just one TTabSheet and with the ShowTabs property of the TPageControl set to false.

It's a work-around that, at least doesn't involved any strange code changes but it's a bit of a weird one. Maybe this information could be useful to the original component author...
« Last Edit: September 28, 2024, 05:39:20 pm by carl_caulkett »
"It builds... ship it!"

 

TinyPortal © 2005-2018