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:
parent
b32dfac5f4
commit
2a30a9e9f1
@ -179,7 +179,7 @@ BControl::MessageReceived(BMessage *message)
|
||||
reply.AddString("result", fLabel);
|
||||
handled = true;
|
||||
} else {
|
||||
// B_GET_PROPERTY
|
||||
// B_SET_PROPERTY
|
||||
const char *label;
|
||||
if (message->FindString("data", &label) == B_OK) {
|
||||
SetLabel(label);
|
||||
@ -192,7 +192,7 @@ BControl::MessageReceived(BMessage *message)
|
||||
reply.AddInt32("result", fValue);
|
||||
handled = true;
|
||||
} else {
|
||||
// B_GET_PROPERTY
|
||||
// B_SET_PROPERTY
|
||||
int32 value;
|
||||
if (message->FindInt32("data", &value) == B_OK) {
|
||||
SetValue(value);
|
||||
@ -205,7 +205,7 @@ BControl::MessageReceived(BMessage *message)
|
||||
reply.AddBool("result", fEnabled);
|
||||
handled = true;
|
||||
} else {
|
||||
// B_GET_PROPERTY
|
||||
// B_SET_PROPERTY
|
||||
bool enabled;
|
||||
if (message->FindBool("data", &enabled) == B_OK) {
|
||||
SetEnabled(enabled);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <ControlLook.h>
|
||||
#include <LayoutUtils.h>
|
||||
#include <Message.h>
|
||||
#include <PropertyInfo.h>
|
||||
#include <Region.h>
|
||||
#include <Window.h>
|
||||
|
||||
@ -40,6 +41,18 @@
|
||||
#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 {
|
||||
public:
|
||||
LabelLayoutItem(BTextControl* parent);
|
||||
@ -542,40 +555,55 @@ BTextControl::SetFlags(uint32 flags)
|
||||
|
||||
|
||||
void
|
||||
BTextControl::MessageReceived(BMessage *msg)
|
||||
BTextControl::MessageReceived(BMessage *message)
|
||||
{
|
||||
switch(msg->what) {
|
||||
case B_SET_PROPERTY:
|
||||
case B_GET_PROPERTY:
|
||||
// TODO: implement these.
|
||||
|
||||
// fall through and pass to BControl
|
||||
// until implemented - note that we will still
|
||||
// need to pass these up the chain for any scripting
|
||||
// messages we don't handle ourselves regardless.
|
||||
default:
|
||||
BControl::MessageReceived(msg);
|
||||
break;
|
||||
if (message->what == B_GET_PROPERTY || message->what == B_SET_PROPERTY) {
|
||||
BMessage reply(B_REPLY);
|
||||
bool handled = false;
|
||||
|
||||
BMessage specifier;
|
||||
int32 index;
|
||||
int32 form;
|
||||
const char *property;
|
||||
if (message->GetCurrentSpecifier(&index, &specifier, &form, &property) == B_OK) {
|
||||
if (strcmp(property, "Value") == 0) {
|
||||
if (message->what == B_GET_PROPERTY) {
|
||||
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 *
|
||||
BTextControl::ResolveSpecifier(BMessage *msg, int32 index,
|
||||
BMessage *specifier, int32 form,
|
||||
BTextControl::ResolveSpecifier(BMessage *message, int32 index,
|
||||
BMessage *specifier, int32 what,
|
||||
const char *property)
|
||||
{
|
||||
/*
|
||||
BPropertyInfo propInfo(prop_list);
|
||||
BHandler *target = NULL;
|
||||
BPropertyInfo propInfo(sPropertyList);
|
||||
|
||||
if (propInfo.FindMatch(message, 0, specifier, what, property) < B_OK)
|
||||
return BControl::ResolveSpecifier(message, index, specifier, what,
|
||||
property);
|
||||
else
|
||||
if (propInfo.FindMatch(message, 0, specifier, what, property) >= B_OK)
|
||||
return this;
|
||||
*/
|
||||
return BControl::ResolveSpecifier(msg, index, specifier, form, property);
|
||||
|
||||
return BControl::ResolveSpecifier(message, index, specifier, what,
|
||||
property);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user