Forum > General
[SOLVED] FileListBox losing focus
Jumbo:
This is about a program I used for some years and wrote it myself.
In short, a form with a filelistbox, the entries are clickable. When selected an entry, a second form draws a figure.
In the past, not sure about when I used it last time, I could select an entry in the list and put my finger on the up or down key
and then the list was scrolled up or down and each entry would "OnChange" draw a figure.
Very funny to see all the figures flashing by...
( The figures are airfoil profiles if it matters to you , drawn from a coordinate list )
This ran for a long time fine, on linux mint.
But now the background pops up between the selections and the focus is lost.
So now the every 2 or 10 "changes" in the list the focus is lost and I need to click on some entry to start scolling again.
For some reason I think linux mint is causing the problem but I cannot be sure about it.
Does someone recognise this behaivior ?
Nicole:
The chances, I have it, are small. The effort to try is low.
I came from Delphi under Window and to my old projects new as well.
Give it a try to change "scroll width".
balazsszekely:
@Jumbo
If I understood you correctly, you do the drawing on the FileListBox OnChange event and sometimes the focus is lost for some reason? I cannot reproduce this issue at my side, however you can try the following:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FileListBox1Change(Sender: TObject);begin //drawing to the second form //... Self.BringToFront; TFileListBox(Sender).SetFocus;end; It would be nice to know why the focus is lost though.
Jumbo:
Thanks for the quick response.
I made a seperate procedure for setfocus:
procedure TForm1.setFocus(Sender: TObject);
begin
Self.BringToFront;
TFileListBox(Sender).SetFocus;
FileListBox1.SetFocus;
end;
It works ! But the result is a very flashing listbox-form...
Every new selection the whole Form is repainted.
Say a 100 entries, then a 99 repaints.
I am pretty sure it did not work this way before.
<ot>
Could it be a collision between Lazarus/pascal and linux-mint/xfce at the other hand?
I have an issue with firefox/youtube-video an the zoom funktion in xfce.
When zooming, the video becomes flashing and then disappears.
From the mint-guys I get no answer to this question.
But from the outside, the behaivier look the same as for the pascal-form
</ot>
Jumbo:
Alright, maby I was quick to react. But it fails still but less then without the focus procedure.
Can even have them displayed all without a lost focus.
What My eye got in de console/devellop env.
This message: NOTE: Window with stalled focus found!, faking focus-out event.
Maybe that does tell someone something ?
Btw: If not a separate procedure does not make a difference:
procedure TForm1.FileListBox1Change(Sender: TObject);
var
myFile: String;
begin
myFile := FileListBox1.FileName;
Form2.myFile := myFile;
Form2.Show;
Form2.setTitle(myFile);
Form2.showFoil();
//Form1.SetFocus(Sender);
Self.BringToFront;
TFileListBox(Sender).SetFocus;
FileListBox1.SetFocus;
end;
Navigation
[0] Message Index
[#] Next page