Article View: comp.windows.interviews
Article #622Re: FieldEditor help
From: Doug Pan
Date: Mon, 28 Sep 1992 21:47
Date: Mon, 28 Sep 1992 21:47
79 lines
2985 bytes
2985 bytes
In article <1992Sep28.225803.570@cssc-syd.tansu.com.au> richardf@cssc-syd.tansu.com.au (Richard Favero) writes:
Could someone send me a small example of how to use a field editor
and the associated action. I dont understand the usage.
FieldEditorCallback::accept is called when RET is entered.
FieldEditorCallback::cancel is called when ESC or '^G' is entered.
The following program outputs the string in the FieldEditor with
"accept/cancel" depending on what you typed.
#include <IV-look/dialogs.h>
#include <IV-look/field.h>
#include <IV-look/kit.h>
#include <InterViews/layout.h>
#include <InterViews/session.h>
#include <InterViews/window.h>
#include <OS/string.h>
#include <stdio.h>
class PrintIt {
public:
virtual void accept(FieldEditor*);
virtual void cancel(FieldEditor*);
};
declareFieldEditorCallback(PrintIt)
implementFieldEditorCallback(PrintIt)
void PrintIt::accept(FieldEditor* e) {
if (e != nil) {
printf("accept: %s\n", e->text()->string());
}
}
void PrintIt::cancel(FieldEditor* e) {
if (e != nil) {
printf("cancel: %s\n", e->text()->string());
}
}
int main (int argc, char** argv) {
Session* session = new Session("Namer", argc, argv);
WidgetKit& kit = *WidgetKit::instance();
const LayoutKit& layout = *LayoutKit::instance();
const DialogKit& dialog = *DialogKit::instance();
PrintIt action;
session->run_window(
new ApplicationWindow(
kit.inset_frame(
layout.margin(
layout.vbox(
layout.hbox(
layout.vcenter(kit.label("Name:")),
layout.hspace(5.0),
layout.vcenter(
dialog.field_editor(
" ", kit.style(),
new FieldEditorCallback(PrintIt)(
&action,
&PrintIt::accept,
&PrintIt::cancel
)
)
)
),
layout.vspace(10.0),
layout.hbox(
layout.hglue(50),
kit.push_button("Quit", kit.quit())
)
),
20.0
)
)
)
);
}
Technical Details
Message-ID:
<PAN.92Sep28214731@panda.Stanford.EDU>Path:
arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!leland.Stanford.EDU!leland!panReferences:
<1992Sep28.225803.570@cssc-syd.tansu.com.au>Show Full Headers
Complete Article Headers
Newsgroups: comp.windows.interviews Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!leland.Stanford.EDU!leland!pan From: pan@panda.Stanford.EDU (Doug Pan) Subject: Re: FieldEditor help In-Reply-To: richardf@cssc-syd.tansu.com.au's message of 28 Sep 92 22:58:03 GMT Message-ID: <PAN.92Sep28214731@panda.Stanford.EDU> Sender: news@leland.Stanford.EDU (Mr News) Organization: Stanford University References: <1992Sep28.225803.570@cssc-syd.tansu.com.au> Date: 28 Sep 92 21:47:31 Lines: 79