Hello, I just needed a read-only WLineEdit and was interested, if
read-only is server-side or only client-side. Bad news is, it's only
client-side, so WLineEdit::text () in combination with  
WLineEdit::setReadOnly
is *not* reliable. I simply created a WLineEdit with some value and
set read-only to true. When I click inside the WLineEdit (in the  
browser..),
its read-only, as expected. Then, I changed the "value" attribute of the
input tag (using Opera Dragonfly) to something else. After that, I used
WLineEdit::text to get the current text and output it in std::cerr and
to my surprise, it shows the changed text. I think this is a (depending
on the situation) pretty dangerous bug.

Example: http://i.imgur.com/6XcOQ.png

=== EXAMPLE SOURCE (PLEASE OMIT IN REPLIES) ===
/*
  * Obviously based on the hello world example.
  */
#include <Wt/WApplication>
#include <Wt/WBreak>
#include <Wt/WContainerWidget>
#include <Wt/WLineEdit>
#include <Wt/WPushButton>
#include <Wt/WText>

using namespace Wt;

class HelloApplication : public WApplication
{
public:
   HelloApplication(const WEnvironment& env);

private:
   WLineEdit *nameEdit_;
   WText *greeting_;

   void greet();
};

HelloApplication::HelloApplication(const WEnvironment& env)
   : WApplication(env)
{
   setTitle("Hello world");                               // application  
title

   root()->addWidget(new WText("Your name, please ? "));  // show some text
   nameEdit_ = new WLineEdit("SomeValue", root());        // allow text  
input
   nameEdit_->setFocus();                                 // give focus

   WPushButton *b = new WPushButton("Greet me.", root()); // create a button
   b->setMargin(5, Left);                                 // add 5 pixels  
margin

   root()->addWidget(new WBreak());                       // insert a line  
break

   greeting_ = new WText(root());                         // empty text

   // Lets set nameEdit_ to read-only
   nameEdit_->setReadOnly (true);

   b->clicked().connect(this, &HelloApplication::greet);

   nameEdit_->enterPressed().connect
     (boost::bind(&HelloApplication::greet, this));

}

void HelloApplication::greet()
{
   greeting_->setText("Hello there, " + nameEdit_->text());
}

WApplication *createApplication(const WEnvironment& env)
{
   return new HelloApplication(env);
}

int main(int argc, char **argv)
{
   return WRun(argc, argv, &createApplication);
}

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to