Embedding multible java applets and focus problem
Koos Vriezen
koos.vriezen at xs4all.nl
Mon Oct 20 22:02:29 BST 2003
I wrote eight days ago:
> Another thing is focus on applets (again), a java text box doesn't get any
> keys delivered when it has the focus.
Ok, I can fix it by making KJavaAppletWidget a child of a wrapper QWidget.
Currently, the kjavaappletviewer sets the QXEmbed as the part widget.
Reading the comments in QXEmbed::reparent, it should be done anyways
(seems to work even better than before :) and nsviewer does this too.
Koos
-------------- next part --------------
Index: kjavaappletviewer.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/java/kjavaappletviewer.h,v
retrieving revision 1.9
diff -u -3 -p -r1.9 kjavaappletviewer.h
--- kjavaappletviewer.h 13 Jul 2003 11:20:13 -0000 1.9
+++ kjavaappletviewer.h 20 Oct 2003 20:48:40 -0000
@@ -82,7 +82,7 @@ public:
KJavaAppletViewer (QWidget * wparent, const char * wname,
QObject * parent, const char * name, const QStringList &args);
~KJavaAppletViewer ();
- KJavaAppletWidget * view () const { return m_view; }
+ KJavaAppletWidget * view () const { return m_appletwidget; }
static KAboutData* createAboutData ();
KJavaAppletViewerBrowserExtension * browserextension() const
@@ -101,7 +101,8 @@ public slots:
protected:
bool openFile();
private:
- QGuardedPtr <KJavaAppletWidget> m_view;
+ KJavaAppletWidget * m_appletwidget;
+ QGuardedPtr <QWidget> m_view;
KConfig * m_config;
KJavaProcess * process;
KJavaAppletViewerBrowserExtension * m_browserextension;
Index: kjavaappletviewer.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/java/kjavaappletviewer.cpp,v
retrieving revision 1.23
diff -u -3 -p -r1.23 kjavaappletviewer.cpp
--- kjavaappletviewer.cpp 1 Oct 2003 20:18:28 -0000 1.23
+++ kjavaappletviewer.cpp 20 Oct 2003 20:48:40 -0000
@@ -26,6 +26,7 @@
#include <qtable.h>
#include <qpair.h>
#include <qguardedptr.h>
+#include <qlayout.h>
#include <klibloader.h>
#include <kaboutdata.h>
@@ -174,11 +175,15 @@ KJavaAppletViewer::KJavaAppletViewer (QW
serverMaintainerDeleter.setObject (serverMaintainer,
new KJavaServerMaintainer);
}
- m_view = new KJavaAppletWidget (wparent);
+ m_view = new QWidget (wparent);
+ QVBoxLayout *layout = new QVBoxLayout (m_view);
+ m_appletwidget = new KJavaAppletWidget (m_view);
+ layout->addWidget (m_appletwidget);
+ m_view->setFocusProxy (m_appletwidget);
QString classname, classid, codebase, khtml_codebase;
int width = -1;
int height = -1;
- KJavaApplet * applet = m_view->applet ();
+ KJavaApplet * applet = m_appletwidget->applet ();
QStringList::const_iterator it = args.begin ();
for ( ; it != args.end (); ++it) {
int equalPos = (*it).find("=");
@@ -308,14 +313,14 @@ bool KJavaAppletViewer::eventFilter (QOb
}
KJavaAppletViewer::~KJavaAppletViewer () {
- m_view = (KJavaAppletWidget*) 0;
+ m_view = (QWidget*) 0;
serverMaintainer->releaseContext (parent(), baseurl);
}
bool KJavaAppletViewer::openURL (const KURL & url) {
if (!m_view) return false;
m_closed = false;
- KJavaApplet * applet = m_view->applet ();
+ KJavaApplet * applet = m_appletwidget->applet ();
if (applet->isCreated ())
applet->stop ();
if (applet->appletClass ().isEmpty ()) {
@@ -325,12 +330,12 @@ bool KJavaAppletViewer::openURL (const K
applet->setBaseURL (url.upURL ().url ());
} else
applet->setAppletClass (url.url ());
- AppletParameterDialog (m_view).exec ();
- applet->setSize (m_view->sizeHint());
+ AppletParameterDialog (m_appletwidget).exec ();
+ applet->setSize (m_appletwidget->sizeHint());
}
// delay showApplet if size is unknown and m_view not shown
if (applet->size().width() > 0 || m_view->isVisible())
- m_view->showApplet ();
+ m_appletwidget->showApplet ();
emit started (0L);
return url.isValid ();
}
@@ -338,7 +343,7 @@ bool KJavaAppletViewer::openURL (const K
bool KJavaAppletViewer::closeURL () {
kdDebug(6100) << "closeURL" << endl;
m_closed = true;
- KJavaApplet * applet = m_view->applet ();
+ KJavaApplet * applet = m_appletwidget->applet ();
if (applet->isCreated ())
applet->stop ();
applet->getContext()->getServer()->endWaitForReturnData();
@@ -347,7 +352,7 @@ bool KJavaAppletViewer::closeURL () {
bool KJavaAppletViewer::appletAlive () const {
return !m_closed && m_view &&
- m_view->applet () && m_view->applet ()->isAlive ();
+ m_appletwidget->applet () && m_appletwidget->applet ()->isAlive ();
}
bool KJavaAppletViewer::openFile () {
@@ -355,7 +360,7 @@ bool KJavaAppletViewer::openFile () {
}
void KJavaAppletViewer::appletLoaded () {
- KJavaApplet * applet = m_view->applet ();
+ KJavaApplet * applet = m_appletwidget->applet ();
if (applet->isAlive() || applet->failed())
emit completed();
}
More information about the kfm-devel
mailing list