Focus Problem
- Posted by DonCole Jan 07, 2013
- 1104 views
Hello Everybody,
This is my code:
-- code generated by Win32Lib IDE v0.22.0 Build Dec-16-2006 constant TheProgramType="exw" include Win32Lib.ew without warning --include myfile.e include bgets.e -------------------------------------------------------------------------------- -- Window Window1 global constant Window1 = createEx( Window, "Window1", 0, Default, Default, 400, 300, 0, 0 ) global constant Menu_101 = createEx( Menu, "pages", Window1, 0, 0, 0, 0, 0, 0 ) global constant MenuItem_102 = createEx( MenuItem, "page a", Menu_101, 0, 0, 0, 0, 0, 0 ) global constant MenuItem_103 = createEx( MenuItem, "page b", Menu_101, 0, 0, 0, 0, 0, 0 ) global constant EditText2 = createEx( EditText, "EditText2", Window1, 48, 44, 84, 24, 0, 0 ) global constant EditText5 = createEx( EditText, "EditText5", Window1, 236, 44, 84, 24, 0, 0 ) global constant EditText3 = createEx( EditText, "EditText3", Window1, 48, 92, 84, 24, 0, 0 ) global constant EditText6 = createEx( EditText, "EditText6", Window1, 236, 92, 84, 24, 0, 0 ) global constant EditText4 = createEx( EditText, "EditText4", Window1, 48, 140, 84, 24, 0, 0 ) global constant EditText7 = createEx( EditText, "EditText7", Window1, 236, 140, 84, 24, 0, 0 ) constant ETs={EditText2,EditText3,EditText4,EditText5,EditText6,EditText7} --------------------------------------------------------- global procedure save_file_bin(sequence db,sequence file_name)--was save_file integer fn fn = open(file_name, "wb") bprint(fn,db) close(fn) end procedure global function get_file_bin(sequence file_name)--binary file was get_file() integer fn object database fn=exist(file_name) if fn=0 then --does not exist fn=open(file_name,"wb") end if fn = open(file_name, "rb") --?fn if fn = -1 then puts(1,"Can't open file:"& file_name) pause() return {} end if database = bget(fn) close(fn) if length(database)<2 then --?length(database) --?9/0 return {} else return database[2] end if end function procedure save_ETs(sequence page) sequence data -- data={} data=repeat({},6) for x=1 to 6 do data[x]=getText(ETs[x]) end for save_file_bin(data,page) end procedure procedure load_ETs(sequence file) sequence data data=get_file_bin(file) for x=1 to 6 do setText(ETs[x],data[x]) end for save_file_bin(data,file) end procedure ------------------------A-------------------------------------------------------- procedure MenuItem_102_onClick (integer self, integer event, sequence params)--params is () if match("B",getText(Window1)) then save_ETs("B.dat") load_ETs("A.dat") setText(Window1,"page A") setFocus(ETs[1]) end if end procedure setHandler( MenuItem_102, w32HClick, routine_id("MenuItem_102_onClick")) ------------------------B-------------------------------------------------------- procedure MenuItem_103_onClick (integer self, integer event, sequence params)--params is () if match("A",getText(Window1)) then save_ETs("A.dat") load_ETs("B.dat") setText(Window1,"page B") setFocus(ETs[1]) end if end procedure setHandler( MenuItem_103, w32HClick, routine_id("MenuItem_103_onClick")) procedure Window1_onActivate (integer self, integer event, sequence params)--params is () for x=1 to 6 do setText(ETs[x],x) end for setText(Window1,"page A") setFocus(ETs[1]) end procedure setHandler( Window1, w32HActivate, routine_id("Window1_onActivate")) WinMain( Window1,Normal )
What I am trying to do is create 2 pages using the same set of EditTexts.
This is working. If you change the numbers on one page they will stay changed when you come back to that page.
In other words you can have two pages with different sets of numbers on each page.
The problem is that once I change pages I loose full focus and can't get it back.
When I say full focus I mean the entire number is printed in reverse. Not a blinking line on the left of the number.
Any help appreciated.
Don Cole