Python
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives Mailing Lists Python

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old March 16th, 2008, 08:50 PM
C M
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
wxSearchCtrl and mouse down problem

I am trying to use wxSearchCtrl such that clicking in it will clear
the initially placed value, but having a problem

The problem is that the mouse LeftDown event only works if you
click in a precise place in the SearchCtrl, which is just to the right of
the bitmap. This isn't the case in a TextCtrl, in which you click
anywhere and it will generate the mouse down event.

I have attached a runnable sample that shows this difference. I am
not sure what the issue is, though I imagine it has something to do
with the control's built-in showing of the word "search" as a default
or something like that. But I would like the SearchCtrl to be able
to be clicked *anywhere* in it and have that generate the event and thus
clear it.

Any help is appreciated. Runnable sample follows:

#
#Boa:Frame:Frame1

import wx

def create(parent):
return Frame1(parent)

[wxID_FRAME1, wxID_FRAME1PANEL1, wxID_FRAME1SEARCHCTRL1,
wxID_FRAME1STATICTEXT1, wxID_FRAME1STATICTEXT2, wxID_FRAME1TEXTCTRL1,
] = [wx.NewId() for _init_ctrls in range(6)]

class Frame1(wx.Frame):
def _init_ctrls(self, prnt):
# generated method, don't edit
wx.Frameinit__(self, id=wxID_FRAME1, name='', parent=prnt,
pos=wx.Point(298, 205), size=wx.Size(344, 164),
style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
self.SetClientSize(wx.Size(336, 130))

self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1',
parent=self,
pos=wx.Point(0, 0), size=wx.Size(336, 130),
style=wx.TAB_TRAVERSAL)

self.searchCtrl1 = wx.SearchCtrl(id=wxID_FRAME1SEARCHCTRL1,
name='searchCtrl1', parent=self.panel1, pos=wx.Point(16, 88),
size=wx.Size(296, 21), style=0,
value=u'this only works if you click just to the right of the
bitmap')
self.searchCtrl1.Bind(wx.EVT_LEFT_DWN, SearchCtrl1LeftDown)

self.textCtrl1 = wx.TextCtrl(id=wxID_FRAME1TEXTCTRL1,
name='textCtrl1',
parent=self.panel1, pos=wx.Point(16, 32), size=wx.Size(299,
21),
style=0, value=u'try to clear this by clicking in it
anywhere')
self.textCtrl1.Bind(wx.EVT_LEFT_DWN, TextCtrl1LeftDown)

self.staticText1 = wx.StaticText(id=wxID_FRAME1STATICTEXT1,
label=u'A SearcCtrl clearing unless',
name='staticText1', parent=self.panel1, pos=wx.Point(16, 72),
size=wx.Size(189, 13), style=0)

self.staticText2 = wx.StaticText(id=wxID_FRAME1STATICTEXT2,
label=u'A TextCtrl clear by clicking anywhere',
name='staticText2', parent=self.panel1, pos=wx.Point(16, 16),
size=wx.Size(203, 13), style=0)

def __init__(self, parent):
self._init_ctrls(parent)
#(False)

def SearchCtrl1LeftDown(self, event):
self.searchCtrl1.Clear()

def TextCtrl1LeftDown(self, event):
self.textCtrl1.Clear()

if __name__ == '__main__':
app = wx.PySimpleApp()
frame = create(None)
frame.Show()

app.MainLoop()

Reply With Quote
Reply

Viewing: Web Development Archives Mailing Lists Python > wxSearchCtrl and mouse down problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT