Implemented BTextControl's string "Value" property. This fixes ticket #3494.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29982 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -179,7 +179,7 @@ BControl::MessageReceived(BMessage *message)
|
|||||||
reply.AddString("result", fLabel);
|
reply.AddString("result", fLabel);
|
||||||
handled = true;
|
handled = true;
|
||||||
} else {
|
} else {
|
||||||
// B_GET_PROPERTY
|
// B_SET_PROPERTY
|
||||||
const char *label;
|
const char *label;
|
||||||
if (message->FindString("data", &label) == B_OK) {
|
if (message->FindString("data", &label) == B_OK) {
|
||||||
SetLabel(label);
|
SetLabel(label);
|
||||||
@@ -192,7 +192,7 @@ BControl::MessageReceived(BMessage *message)
|
|||||||
reply.AddInt32("result", fValue);
|
reply.AddInt32("result", fValue);
|
||||||
handled = true;
|
handled = true;
|
||||||
} else {
|
} else {
|
||||||
// B_GET_PROPERTY
|
// B_SET_PROPERTY
|
||||||
int32 value;
|
int32 value;
|
||||||
if (message->FindInt32("data", &value) == B_OK) {
|
if (message->FindInt32("data", &value) == B_OK) {
|
||||||
SetValue(value);
|
SetValue(value);
|
||||||
@@ -205,7 +205,7 @@ BControl::MessageReceived(BMessage *message)
|
|||||||
reply.AddBool("result", fEnabled);
|
reply.AddBool("result", fEnabled);
|
||||||
handled = true;
|
handled = true;
|
||||||
} else {
|
} else {
|
||||||
// B_GET_PROPERTY
|
// B_SET_PROPERTY
|
||||||
bool enabled;
|
bool enabled;
|
||||||
if (message->FindBool("data", &enabled) == B_OK) {
|
if (message->FindBool("data", &enabled) == B_OK) {
|
||||||
SetEnabled(enabled);
|
SetEnabled(enabled);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include <ControlLook.h>
|
#include <ControlLook.h>
|
||||||
#include <LayoutUtils.h>
|
#include <LayoutUtils.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
|
#include <PropertyInfo.h>
|
||||||
#include <Region.h>
|
#include <Region.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
@@ -40,6 +41,18 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static property_info sPropertyList[] = {
|
||||||
|
{
|
||||||
|
"Value",
|
||||||
|
{ B_GET_PROPERTY, B_SET_PROPERTY },
|
||||||
|
{ B_DIRECT_SPECIFIER },
|
||||||
|
NULL, 0,
|
||||||
|
{ B_STRING_TYPE }
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class BTextControl::LabelLayoutItem : public BAbstractLayoutItem {
|
class BTextControl::LabelLayoutItem : public BAbstractLayoutItem {
|
||||||
public:
|
public:
|
||||||
LabelLayoutItem(BTextControl* parent);
|
LabelLayoutItem(BTextControl* parent);
|
||||||
@@ -542,40 +555,55 @@ BTextControl::SetFlags(uint32 flags)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BTextControl::MessageReceived(BMessage *msg)
|
BTextControl::MessageReceived(BMessage *message)
|
||||||
{
|
{
|
||||||
switch(msg->what) {
|
if (message->what == B_GET_PROPERTY || message->what == B_SET_PROPERTY) {
|
||||||
case B_SET_PROPERTY:
|
BMessage reply(B_REPLY);
|
||||||
case B_GET_PROPERTY:
|
bool handled = false;
|
||||||
// TODO: implement these.
|
|
||||||
|
BMessage specifier;
|
||||||
// fall through and pass to BControl
|
int32 index;
|
||||||
// until implemented - note that we will still
|
int32 form;
|
||||||
// need to pass these up the chain for any scripting
|
const char *property;
|
||||||
// messages we don't handle ourselves regardless.
|
if (message->GetCurrentSpecifier(&index, &specifier, &form, &property) == B_OK) {
|
||||||
default:
|
if (strcmp(property, "Value") == 0) {
|
||||||
BControl::MessageReceived(msg);
|
if (message->what == B_GET_PROPERTY) {
|
||||||
break;
|
reply.AddString("result", fText->Text());
|
||||||
|
handled = true;
|
||||||
|
} else {
|
||||||
|
const char *value = NULL;
|
||||||
|
// B_SET_PROPERTY
|
||||||
|
if (message->FindString("data", &value) == B_OK) {
|
||||||
|
fText->SetText(value);
|
||||||
|
reply.AddInt32("error", B_OK);
|
||||||
|
handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handled) {
|
||||||
|
message->SendReply(&reply);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BControl::MessageReceived(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BHandler *
|
BHandler *
|
||||||
BTextControl::ResolveSpecifier(BMessage *msg, int32 index,
|
BTextControl::ResolveSpecifier(BMessage *message, int32 index,
|
||||||
BMessage *specifier, int32 form,
|
BMessage *specifier, int32 what,
|
||||||
const char *property)
|
const char *property)
|
||||||
{
|
{
|
||||||
/*
|
BPropertyInfo propInfo(sPropertyList);
|
||||||
BPropertyInfo propInfo(prop_list);
|
|
||||||
BHandler *target = NULL;
|
|
||||||
|
|
||||||
if (propInfo.FindMatch(message, 0, specifier, what, property) < B_OK)
|
if (propInfo.FindMatch(message, 0, specifier, what, property) >= B_OK)
|
||||||
return BControl::ResolveSpecifier(message, index, specifier, what,
|
|
||||||
property);
|
|
||||||
else
|
|
||||||
return this;
|
return this;
|
||||||
*/
|
|
||||||
return BControl::ResolveSpecifier(msg, index, specifier, form, property);
|
return BControl::ResolveSpecifier(message, index, specifier, what,
|
||||||
|
property);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user