May 04, 2024, 02:07:52 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


set focus problem

Started by talun, October 07, 2011, 02:12:02 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

talun

Hi,
In the sample code below, the focus on the listbox rows is set only at the beginning of the program, after the initial page is loaded (it is possible to use the keyboard to select the rows in the listbox).
If you then load other pages using the various links, the focus is no longer set to the listbox after loading new pages (the listbox rows can be selected only with the mouse).
If possible, someone could tell me where I'm wrong?


CONST LISTBOX_1 = 1

window wmain,wbrows

OPENWINDOW wmain,0,0,999,523,@MINBOX|@MAXBOX|@NOAUTODRAW,0,"Focus test",&wmainHndl
OPENWINDOW wbrows,180,13,807,460,@NOAUTODRAW|@NOCAPTION|@BORDER,wmain,"",&wbrowsHndl
CONTROL wmain,@LISTBOX,"ListBox1",8,13,162,460,0x50800140,LISTBOX_1

setfont wmain,"Sans",10,300,0,LISTBOX_1
addstring wmain,LISTBOX_1,"aaaaa"
addstring wmain,LISTBOX_1,"bbbbb"
addstring wmain,LISTBOX_1,"ccccc"
addstring wmain,LISTBOX_1,"ddddd"
addstring wmain,LISTBOX_1,"eeeee"

IF ATTACHBROWSER(wbrows) <> 0
MESSAGEBOX wmain,"Browser creation failed...","Error!!"
CLOSEWINDOW wbrows
CLOSEWINDOW wmain
END
ELSE
BROWSECMD wbrows,@NAVIGATE,"http://www.ionicwind.com"
setfocus wmain,LISTBOX_1
ENDIF

WaitUntil IsWindowClosed(wmain)


SUB wmainHndl(),int

SELECT @CLASS
CASE @IDCLOSEWINDOW
CLOSEWINDOW wbrows
CLOSEWINDOW wmain
ENDSELECT

RETURN 0

ENDSUB


sub wbrowsHndl(),int

SELECT @MESSAGE
CASE @IDNAVCOMPLETE
setfocus wmain,LISTBOX_1
endselect

return 0

end sub


Thanks!

Sergio

LarryMc

I played with your code for a while(over and hour) and I couldn't get it to work either.  I even tried sending messages at different places and couldn't get it to work like I would think it should work.

But my real question is why would you want to do it that way anyway.

If I understand what you want to do; click a link in the browser to go to a web page and immediately shift focus to the listbox.

That would make it so that when you navigated to a webpage that you would have to click on the page after it loaded in order to be able to scroll the page.

Seems to me likeyour example program works the way I would want it to work: nav to a page and be able to scroll it with the keyboard or mouse

Then if I want to make a new selection from the list box I would just click on it.

I guess I'm assuming you are trying to do a variation of what I understand andy is wanting to do.

BTW, the embedded webbrowser uses some OLE stuff.  It might be running in a different thread and that's why it doesn't work the way you have it coded.

I really don't have a clue.

Sorry,

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

talun

Larry,

many thanks for your efforts and I understand your concerns about the usefulness of the program.
The code is used to reproduce a problem I have with a program more complex I wrote to view pdf files in a folder. The names of the files are loaded into a listbox and then displayed in the browser.
It would be so very convenient to use the keyboard to scroll through the names of several files (which are usually very numerous) without using the mouse. That's it.
The thing that intrigues me is why you can not reset the focus to the listbox once it has completed the loading of the document.

Cheers

Sergio