From: John L. <jla...@gm...> - 2005-07-29 16:52:01
|
On 7/28/05, The Doctor <the...@bl...> wrote: > I found some possible problem with that extended toolbar thing. >=20 > A dialog, directly called by tool click, doesn't have focus correctly, an= d I don't yet know why. It takes a click on the main app title bar, or on t= he dialog space, or on the close button on the dialog itself, before any at= tempt to close the dialog window will work. It's as if the focus is somewhe= re completely hidden, and must be recalled before a manual response works. > Do you have any idea why this happens? Also, might some simple method by = applied to make sure the focus or whatever it is allows a proper response t= o the first click on the program windows? (I tried a SetFocus() on the dial= og after ShowModal() but that didn't fix it). dialog:SetFocus() seems to work for me? See "function ReadTool(EV)". Also note that modal dialogs like the file dialog should be local variables to the function that they're called from since they block program flow and it's just as well to create them as necessary. Native dialogs like the file dialog may be destroyed when done. See where I've moved FilePane into "DoThings". Regards, John Labenski > -------------------------------------------------------------------------= -------------------------- >=20 > local FS=3Dwx.wxDEFAULT_FRAME_STYLE-wx.wxMAXIMIZE_BOX-wx.wxRESIZE_BORDER > FRAME=3Dwx.wxFrame(wx.wxNull,-1,"",wx.wxDefaultPosition,wx.wxSize(432,310= ),FS) -- Main GUI frame, supports menus and all good stuffs. >=20 > PANEL=3Dwx.wxPanel(FRAME,-1) = -- Dialog-like control/surface in a Frame. >=20 > BANK=3Dwx.wxDialog(PANEL,-1,"",wx.wxPoint(-1,-1),wx.wxSize(426,266)) = -- Make two identical test dialogs. > CNFG=3Dwx.wxDialog(PANEL,-1,"",wx.wxPoint(-1,-1),wx.wxSize(426,266)) >=20 > IDB=3D0 >=20 > BMP_I=3Dwx.wxBitmapFromFile("Bitmaps/new.bmp",wx.wxBITMAP_TYPE_BMP) > BMP_O=3Dwx.wxBitmapFromFile("Bitmaps/open.bmp",wx.wxBITMAP_TYPE_BMP) > TBAR=3Dwx.wxToolBar(PANEL,ID_TOOLBAR,wx.wxPoint(-1,14),wx.wxSize(-1,-1),w= x.wxTB_FLAT) > TBAR:AddTool(201,BMP_I,wx.wxNullBitmap,wx.FALSE,wx.wxNull,"") > TBAR:AddTool(202,BMP_O,wx.wxNullBitmap,wx.FALSE,wx.wxNull,"") > TBAR:Realize() TBAR:Move(-1,-2) TBAR:SetSize(440,-1) >=20 > TBAR:ConnectEvent(-1,wx.wxEVT_LEFT_DOWN, = -- When any part of the toolbar is left-clicked, look for a tool. > function(EV) IDB=3DFindTool(EV) EV:Skip() end = -- Use Skip() to avoid interference with native left click handler= . > ) >=20 > TBAR:ConnectEvent(-1,wx.wxEVT_LEFT_UP, = -- When a left click on the toolbar is released, call ReadTool(). > function(EV) ReadTool(EV) EV:Skip() end = -- Use Skip() to avoid interference with native left click handler. > ) >=20 > BANK:ConnectEvent(-1,wx.wxEVT_COMMAND_BUTTON_CLICKED, > function(EV) BANK:EndModal(1) end > ) >=20 > CNFG:ConnectEvent(-1,wx.wxEVT_COMMAND_BUTTON_CLICKED, > function(EV) CNFG:EndModal(1) end > ) >=20 > function FindTool(Z) > Z=3DTBAR:FindToolForPosition(Z:GetX(),Z:GetY()) = -- When toolbar (or tool) is clicked, look for tool where clicked. > if Z then Z=3DZ:GetId() end return Z = -- If tool was found, return it's ID, or otherwise return nil. > end >=20 > function DoThings() > FilePane=3Dwx.wxFileDialog(FRAME,"","","","All files (*.*)|*.*",wx.wx= OPEN) > FilePane:ShowModal() --FilePane:EndModal(1) > CNFG:CentreOnParent() CNFG:ShowModal(wx.TRUE) = -- Show selector dialog. Button ID will be set to VN (Voice Number). > end >=20 > function ReadTool(EV) > local ID=3DFindTool(EV) = -- Get the toolbar button's ID, which is how the tool is indexed. > if (ID~=3DIDB) then return end IDB=3D0 = -- If button down/up were not on same tool, do nothing. Reset ID= B. > if (ID=3D=3D201) then BANK:CentreOnParent() BANK:ShowModal(wx.TRUE)= BANK:SetFocus() > elseif (ID=3D=3D202) then DoThings() > end > end >=20 > FRAME:Centre() > FRAME:Show(wx.TRUE) > -------------------------------------------------------------------------= -------------------------- |