本文整理汇总了C++中BTextView::MakeFocus方法的典型用法代码示例。如果您正苦于以下问题:C++ BTextView::MakeFocus方法的具体用法?C++ BTextView::MakeFocus怎么用?C++ BTextView::MakeFocus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BTextView
的用法示例。
在下文中一共展示了BTextView::MakeFocus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BWindow
window() : BWindow(BRect(30, 30, 300, 300), "BTextView test", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS)
{
BTextView *textview = new BTextView(Bounds(), "textview", Bounds(),
B_FOLLOW_ALL, B_WILL_DRAW);
AddChild(textview);
textview->SetText("Type into the Antares BTextView!");
textview->MakeFocus();
}
示例2: entry
void
BTextWidget::StartEdit(BRect bounds, BPoseView *view, BPose *pose)
{
if (!IsEditable())
return;
// don't allow editing of the trash directory name
if (pose->TargetModel()->IsTrash())
return;
// don't allow editing of the "Disks" icon name
if (pose->TargetModel()->IsRoot())
return;
BEntry entry(pose->TargetModel()->EntryRef());
if (entry.InitCheck() == B_OK
&& !ConfirmChangeIfWellKnownDirectory(&entry, "rename"))
return;
// get bounds with full text length
BRect rect(bounds);
BRect textRect(bounds);
rect.OffsetBy(-2, -1);
rect.right += 1;
BFont font;
view->GetFont(&font);
BTextView *textView = new BTextView(rect, "WidgetTextView", textRect, &font, 0,
B_FOLLOW_ALL, B_WILL_DRAW);
textView->SetWordWrap(false);
DisallowMetaKeys(textView);
fText->SetUpEditing(textView);
textView->AddFilter(new BMessageFilter(B_KEY_DOWN, TextViewFilter));
rect.right = rect.left + textView->LineWidth() + 3;
// center new width, if necessary
if (view->ViewMode() == kIconMode
|| (view->ViewMode() == kListMode && fAlignment == B_ALIGN_CENTER)) {
rect.OffsetBy(bounds.Width() / 2 - rect.Width() / 2, 0);
}
rect.bottom = rect.top + textView->LineHeight() + 1;
textRect = rect.OffsetToCopy(2, 1);
textRect.right -= 3;
textRect.bottom--;
textView->SetTextRect(textRect);
textRect = view->Bounds();
bool hitBorder = false;
if (rect.left < 1)
rect.left = 1, hitBorder = true;
if (rect.right > textRect.right)
rect.right = textRect.right - 2, hitBorder = true;
textView->MoveTo(rect.LeftTop());
textView->ResizeTo(rect.Width(), rect.Height());
BScrollView *scrollView = new BScrollView("BorderView", textView, 0, 0, false,
false, B_PLAIN_BORDER);
view->AddChild(scrollView);
// configure text view
switch (view->ViewMode()) {
case kIconMode:
textView->SetAlignment(B_ALIGN_CENTER);
break;
case kMiniIconMode:
textView->SetAlignment(B_ALIGN_LEFT);
break;
case kListMode:
textView->SetAlignment(fAlignment);
break;
}
textView->MakeResizable(true, hitBorder ? NULL : scrollView);
view->SetActivePose(pose); // tell view about pose
SetActive(true); // for widget
textView->SelectAll();
textView->MakeFocus();
// make this text widget invisible while we edit it
SetVisible(false);
ASSERT(view->Window()); // how can I not have a Window here???
if (view->Window())
// force immediate redraw so TextView appears instantly
view->Window()->UpdateIfNeeded();
}
示例3: r
AddWindow::AddWindow() :
BWindow(BRect(250,70,640,270),"AddWindow", B_MODAL_WINDOW, B_NOT_RESIZABLE|B_NOT_ZOOMABLE|B_ASYNCHRONOUS_CONTROLS)
{
BButton* but;
BButton* but2;
BFont font=*(be_plain_font);
BRect r(Bounds());
BBox *box = new BBox(r,"url_bbox", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW, B_FANCY_BORDER);
box->SetBorder(B_PLAIN_BORDER);
AddChild(box);
BRect rect(0, 0, 390, 165);
BMessage templ;
templ.AddString("name", "Add subscription");
BMessage settings;
settings.AddString("name", "rss_url");
settings.AddString("description", "Feed URL");
settings.AddInt32("type", B_STRING_TYPE);
settings.AddBool("multi_line", true);
templ.AddMessage("setting", &settings);
BMessage values;
text = new PBox(rect, templ, values, "rss_url");
text->SetBorder(B_PLAIN_BORDER);
box->AddChild(text);
addrect = box->Bounds();
addrect.InsetBy(25, 20);
addrect.top = addrect.bottom - 12;
addrect.left = addrect.right - font.StringWidth(_T("Cancel")) - 30;
box->AddChild(but = new BButton(addrect,"",_T("Cancel"),new BMessage('can')));
addrect.right = addrect.left - 15;
addrect.left = addrect.right - font.StringWidth(_T("Add")) - 30;
box->AddChild(but2 = new BButton(addrect,"",_T("Add"),new BMessage('sav')));
//controlliamo se c'e' qualcosa nella clipboard?
const char *clip_text = NULL;
bool addButton = false;
int32 textLen;
BString url;
BMessage *clip = (BMessage *)NULL;
if (be_clipboard->Lock() ){
clip = be_clipboard->Data();
if ( clip && ( clip->FindData("text/plain", B_MIME_TYPE,(const void **)&clip_text, &textLen) == B_OK )){
url.SetTo(clip_text,textLen);
if(url.FindFirst("http://") == 0)
addButton = true;
else
if(url.FindFirst("pcast://") == 0)
addButton = true;
else
if(url.FindFirst("feed://") == 0)
addButton = true;
}
be_clipboard->Unlock();
}
if(addButton==true){
addrect.right = addrect.left - 15;
addrect.left = addrect.right - font.StringWidth(_T("Paste")) - 30;
BMessage* msg=new BMessage('past');
msg->AddString("url",url);
BButton* clip_but;
box->AddChild(clip_but = new BButton(addrect,"",_T("Paste"),msg));
}
MoveTo(BPAlert::AlertPosition(Bounds().Width(),Bounds().Height()));
BTextView *textView = (BTextView*)FindView("rss_url");
if (textView){
textView->MakeFocus(true);
}
}
示例4: entry
void
BTextWidget::StartEdit(BRect bounds, BPoseView* view, BPose* pose)
{
view->SetTextWidgetToCheck(NULL, this);
if (!IsEditable() || IsActive())
return;
BEntry entry(pose->TargetModel()->EntryRef());
if (entry.InitCheck() == B_OK
&& !ConfirmChangeIfWellKnownDirectory(&entry,
B_TRANSLATE_COMMENT("rename",
"As in 'if you rename this folder...' (en) "
"'Wird dieser Ordner umbenannt...' (de)"),
B_TRANSLATE_COMMENT("rename",
"As in 'to rename this folder...' (en) "
"'Um diesen Ordner umzubenennen...' (de)"),
B_TRANSLATE_COMMENT("Rename",
"Button label, 'Rename' (en), 'Umbenennen' (de)")))
return;
// get bounds with full text length
BRect rect(bounds);
BRect textRect(bounds);
rect.OffsetBy(-2, -1);
rect.right += 1;
BFont font;
view->GetFont(&font);
BTextView* textView = new BTextView(rect, "WidgetTextView", textRect,
&font, 0, B_FOLLOW_ALL, B_WILL_DRAW);
textView->SetWordWrap(false);
DisallowMetaKeys(textView);
fText->SetUpEditing(textView);
textView->AddFilter(new BMessageFilter(B_KEY_DOWN, TextViewFilter));
rect.right = rect.left + textView->LineWidth() + 3;
// center new width, if necessary
if (view->ViewMode() == kIconMode
|| (view->ViewMode() == kListMode && fAlignment == B_ALIGN_CENTER)) {
rect.OffsetBy(bounds.Width() / 2 - rect.Width() / 2, 0);
}
rect.bottom = rect.top + textView->LineHeight() + 1;
textRect = rect.OffsetToCopy(2, 1);
textRect.right -= 3;
textRect.bottom--;
textView->SetTextRect(textRect);
BPoint origin = view->LeftTop();
textRect = view->Bounds();
bool hitBorder = false;
if (rect.left <= origin.x)
rect.left = origin.x + 1, hitBorder = true;
if (rect.right >= textRect.right)
rect.right = textRect.right - 1, hitBorder = true;
textView->MoveTo(rect.LeftTop());
textView->ResizeTo(rect.Width(), rect.Height());
BScrollView* scrollView = new BScrollView("BorderView", textView, 0, 0,
false, false, B_PLAIN_BORDER);
view->AddChild(scrollView);
// configure text view
switch (view->ViewMode()) {
case kIconMode:
textView->SetAlignment(B_ALIGN_CENTER);
break;
case kMiniIconMode:
textView->SetAlignment(B_ALIGN_LEFT);
break;
case kListMode:
textView->SetAlignment(fAlignment);
break;
}
textView->MakeResizable(true, hitBorder ? NULL : scrollView);
view->SetActivePose(pose);
// tell view about pose
SetActive(true);
// for widget
textView->SelectAll();
textView->MakeFocus();
// make this text widget invisible while we edit it
SetVisible(false);
ASSERT(view->Window() != NULL);
// how can I not have a Window here???
if (view->Window()) {
// force immediate redraw so TextView appears instantly
view->Window()->UpdateIfNeeded();
}
//.........这里部分代码省略.........