当前位置: 首页>>代码示例>>C++>>正文


C++ BPopUpMenu::SetTargetForItems方法代码示例

本文整理汇总了C++中BPopUpMenu::SetTargetForItems方法的典型用法代码示例。如果您正苦于以下问题:C++ BPopUpMenu::SetTargetForItems方法的具体用法?C++ BPopUpMenu::SetTargetForItems怎么用?C++ BPopUpMenu::SetTargetForItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BPopUpMenu的用法示例。


在下文中一共展示了BPopUpMenu::SetTargetForItems方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BMessage

//! Track the mouse without blocking the window
void
CPUButton::MouseDown(BPoint point)
{
    BPoint mousePosition;
    uint32 mouseButtons;

    GetMouse(&mousePosition, &mouseButtons);

    if ((B_PRIMARY_MOUSE_BUTTON & mouseButtons) != 0) {
        SetValue(!Value());
        SetTracking(true);
        SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
    } else if ((B_SECONDARY_MOUSE_BUTTON & mouseButtons) != 0
               && fReplicantInDeskbar) {
        BPopUpMenu *menu = new BPopUpMenu(B_TRANSLATE("Deskbar menu"));
        menu->AddItem(new BMenuItem(B_TRANSLATE("About Pulse" B_UTF8_ELLIPSIS),
                                    new BMessage(B_ABOUT_REQUESTED)));
        menu->AddSeparatorItem();
        menu->AddItem(new BMenuItem(B_TRANSLATE("Remove replicant"),
                                    new BMessage(kDeleteReplicant)));
        menu->SetTargetForItems(this);

        ConvertToScreen(&point);
        menu->Go(point, true, true, true);
    }
}
开发者ID:mmadia,项目名称:haiku-1,代码行数:27,代码来源:CPUButton.cpp

示例2: mouseRect

// MouseDown
void
OptionValueView::MouseDown(BPoint where)
{
	if (BView* parent = Parent())
		parent->MouseDown(ConvertToParent(where));
	
	if (fProperty) {
		BPopUpMenu* menu = new BPopUpMenu("option popup", false, false);
		BString name;
		int32 id;
		for (int32 i = 0; fProperty->GetOption(i, &name, &id); i++) {
			BMessage* message = new BMessage(MSG_OPTION_CHANGED);
			message->AddInt32("id", id);
			BMenuItem* item = new BMenuItem(name.String(), message);
			menu->AddItem(item);
			if (id == fProperty->CurrentOptionID())
				item->SetMarked(true);
		}
		menu->SetTargetForItems(this);
		menu->SetAsyncAutoDestruct(true);
		menu->SetFont(be_plain_font);
		menu->SetEnabled(fEnabled);

		where = ConvertToScreen(where);
		BRect mouseRect(where, where);
		mouseRect.InsetBy(-10.0, -10.0);
		where += BPoint(5.0, 5.0);
		menu->Go(where, true, false, mouseRect, true);
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:31,代码来源:OptionValueView.cpp

示例3: BMessage

void
PowerStatusReplicant::MouseDown(BPoint point)
{
	BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false);
	menu->SetFont(be_plain_font);

	BMenuItem* item;
	menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show text label"),
		new BMessage(kMsgToggleLabel)));
	if (fShowLabel)
		item->SetMarked(true);
	menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show status icon"),
		new BMessage(kMsgToggleStatusIcon)));
	if (fShowStatusIcon)
		item->SetMarked(true);
	menu->AddItem(new BMenuItem(!fShowTime ? B_TRANSLATE("Show time") :
	B_TRANSLATE("Show percent"),
		new BMessage(kMsgToggleTime)));

	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem(B_TRANSLATE("Battery info" B_UTF8_ELLIPSIS),
		new BMessage(kMsgToggleExtInfo)));

	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem(B_TRANSLATE("About" B_UTF8_ELLIPSIS),
		new BMessage(B_ABOUT_REQUESTED)));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), 
		new BMessage(B_QUIT_REQUESTED)));
	menu->SetTargetForItems(this);

	ConvertToScreen(&point);
	menu->Go(point, true, false, true);
}
开发者ID:RTOSkit,项目名称:haiku,代码行数:33,代码来源:PowerStatusView.cpp

示例4: GeneratePopUp

void StatusItem::GeneratePopUp(BPoint point, BRect openrect)
{
	BString str(value);
	str.Append(" ");
	BString url;
	URLCrunch crunch(str.String(), str.Length());
	BPopUpMenu* menu = new BPopUpMenu("URLs");
	BMessage msg(M_LOAD_URL);
	BMessage* allocmsg(NULL);
	BMenuItem* item(NULL);

	while (crunch.Crunch(&url) != B_ERROR) {
		allocmsg = new BMessage(msg);
		allocmsg->AddString("url", url.String());
		item = new BMenuItem(url.String(), allocmsg);
		menu->AddItem(item);
		allocmsg = NULL;
	}

	if (menu->CountItems() > 0) {
		menu->SetTargetForItems(be_app);
		menu->SetAsyncAutoDestruct(true);
		menu->Go(point, true, true, openrect, true);
	} else {
		delete menu;
	}
}
开发者ID:carriercomm,项目名称:Vision,代码行数:27,代码来源:StatusView.cpp

示例5: showContextMenu

void MediaJack::showContextMenu(
	BPoint point)
{
	D_METHOD(("MediaJack::showContextMenu()\n"));

	BPopUpMenu *menu = new BPopUpMenu("MediaJack PopUp", false, false, B_ITEMS_IN_COLUMN);
	menu->SetFont(be_plain_font);
	BMenuItem *item;

	// add the "Get Info" item
	if (isInput())
	{
		media_input input;
		getInput(&input);
		BMessage *message = new BMessage(InfoWindowManager::M_INFO_WINDOW_REQUESTED);
		message->AddData("input", B_RAW_TYPE,
						 reinterpret_cast<const void *>(&input), sizeof(input));
		menu->AddItem(item = new BMenuItem("Get info", message));
	}
	else if (isOutput())
	{
		media_output output;
		getOutput(&output);
		BMessage *message = new BMessage(InfoWindowManager::M_INFO_WINDOW_REQUESTED);
		message->AddData("output", B_RAW_TYPE,
						 reinterpret_cast<const void *>(&output), sizeof(output));
		menu->AddItem(item = new BMenuItem("Get info", message));
	}

	menu->SetTargetForItems(view());
	view()->ConvertToScreen(&point);
	point -= BPoint(1.0, 1.0);
	menu->Go(point, true, true, true);
}
开发者ID:mariuz,项目名称:haiku,代码行数:34,代码来源:MediaJack.cpp

示例6: predicate

void
JobSetupView::AddPopUpMenu(const DriverSpecificCap* capability,
	BGridLayout* gridLayout, int& row)
{
	const char* label = capability->fLabel.c_str();
	BPopUpMenu* popUpMenu = new BPopUpMenu(label);
	popUpMenu->SetRadioMode(true);

	PrinterCap::CapID category = static_cast<PrinterCap::CapID>(
		capability->ID());

	const BaseCap** categoryCapabilities = fPrinterCap->GetCaps(category);

	int categoryCount = fPrinterCap->CountCap(category);

	string value = GetDriverSpecificValue(category, capability->Key());
	PrinterCap::KeyPredicate predicate(value.c_str());

	FillCapabilityMenu(popUpMenu, kMsgNone, categoryCapabilities,
		categoryCount, predicate);

	BString menuLabel = label;
	menuLabel << ":";
	BMenuField* menuField = new BMenuField(label, menuLabel.String(),
		popUpMenu);
	popUpMenu->SetTargetForItems(this);

	gridLayout->AddItem(menuField->CreateLabelLayoutItem(),
		0, row);
	gridLayout->AddItem(menuField->CreateMenuBarLayoutItem(),
		1, row);
	row ++;

	fDriverSpecificPopUpMenus[category] = popUpMenu;
}
开发者ID:,项目名称:,代码行数:35,代码来源:

示例7: BMessage

void
TTimeView::ShowTimeOptions(BPoint point)
{
	BPopUpMenu* menu = new BPopUpMenu("", false, false);
	menu->SetFont(be_plain_font);
	BMenuItem* item;

	item = new BMenuItem(B_TRANSLATE("Time preferences" B_UTF8_ELLIPSIS),
		new BMessage(kChangeTime));
	menu->AddItem(item);

	item = new BMenuItem(B_TRANSLATE("Hide time"),
		new BMessage(kShowHideTime));
	menu->AddItem(item);

	item = new BMenuItem(B_TRANSLATE("Show calendar" B_UTF8_ELLIPSIS),
		new BMessage(kShowCalendar));
	menu->AddItem(item);

	menu->SetTargetForItems(this);
	// Changed to accept screen coord system point;
	// not constrained to this view now
	menu->Go(point, true, true, BRect(point.x - 4, point.y - 4,
		point.x + 4, point.y +4), true);
}
开发者ID:ysei,项目名称:haiku,代码行数:25,代码来源:TimeView.cpp

示例8: BMessage

void
StatusView::MouseDown(BPoint where)
{
	if (!fReadOnly)
		return;

	float left = fCellWidth[kPositionCell] + fCellWidth[kEncodingCell];
	if (where.x < left)
		return;

	int32 clicks = 0;
	BMessage* message = Window()->CurrentMessage();
	if (message != NULL
		&& message->FindInt32("clicks", &clicks) == B_OK && clicks > 1)
			return;

	BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false);
	menu->AddItem(new BMenuItem(B_TRANSLATE("Unlock file"),
					new BMessage(UNLOCK_FILE)));
	where.x = left;
	where.y = Bounds().bottom;

	ConvertToScreen(&where);
	menu->SetTargetForItems(this);
	menu->Go(where, true, true,	true);
}
开发者ID:,项目名称:,代码行数:26,代码来源:

示例9: mouseRect

// ShowContextMenu
bool
PathManipulator::ShowContextMenu(BPoint where)
{
	// Change the selection to the current point if it isn't currently
	// selected. This could will only be chosen if the user right-clicked
	// a path point directly. 
	if (fCurrentPathPoint >= 0 && !fSelection->Contains(fCurrentPathPoint)) {
		fSelection->MakeEmpty();
		_UpdateSelection();
		*fOldSelection = *fSelection;
		_Select(fCurrentPathPoint, false);
	}

	BPopUpMenu* menu = new BPopUpMenu("context menu", false, false);
	BMessage* message;
	BMenuItem* item;

	bool hasSelection = fSelection->CountItems() > 0;

	if (fCurrentPathPoint < 0) {
		message = new BMessage(B_SELECT_ALL);
		item = new BMenuItem("Select All", message, 'A');
		menu->AddItem(item);
	
		menu->AddSeparatorItem();
	}

	message = new BMessage(MSG_TRANSFORM);
	item = new BMenuItem("Transform", message, 'T');
	item->SetEnabled(hasSelection);
	menu->AddItem(item);

	message = new BMessage(MSG_SPLIT_POINTS);
	item = new BMenuItem("Split", message);
	item->SetEnabled(hasSelection);
	menu->AddItem(item);

	message = new BMessage(MSG_FLIP_POINTS);
	item = new BMenuItem("Flip", message);
	item->SetEnabled(hasSelection);
	menu->AddItem(item);

	message = new BMessage(MSG_REMOVE_POINTS);
	item = new BMenuItem("Remove", message);
	item->SetEnabled(hasSelection);
	menu->AddItem(item);

	// go
	menu->SetTargetForItems(fCanvasView);
	menu->SetAsyncAutoDestruct(true);
	menu->SetFont(be_plain_font);
	where = fCanvasView->ConvertToScreen(where);
	BRect mouseRect(where, where);
	mouseRect.InsetBy(-10.0, -10.0);
	where += BPoint(5.0, 5.0);
	menu->Go(where, true, false, mouseRect, true);

	return true;
}
开发者ID:mariuz,项目名称:haiku,代码行数:60,代码来源:PathManipulator.cpp

示例10: BMessage

void
IconView::MouseDown(BPoint where)
{
	if (!IsEnabled())
		return;

	int32 buttons = B_PRIMARY_MOUSE_BUTTON;
	int32 clicks = 1;
	if (Looper() != NULL && Looper()->CurrentMessage() != NULL) {
		if (Looper()->CurrentMessage()->FindInt32("buttons", &buttons) != B_OK)
			buttons = B_PRIMARY_MOUSE_BUTTON;
		if (Looper()->CurrentMessage()->FindInt32("clicks", &clicks) != B_OK)
			clicks = 1;
	}

	if ((buttons & B_PRIMARY_MOUSE_BUTTON) != 0
		&& BitmapRect().Contains(where)) {
		if (clicks == 2) {
			// double click - open Icon-O-Matic
			Invoke();
		} else if (fIcon != NULL) {
			// start tracking - this icon might be dragged around
			fDragPoint = where;
			fTracking = true;
			SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
		}
	}

	if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
		// show context menu

		ConvertToScreen(&where);

		BPopUpMenu* menu = new BPopUpMenu("context");
		menu->SetFont(be_plain_font);

		bool hasIcon = fHasType ? fSource == kOwnIcon : fIcon != NULL;
		if (hasIcon) {
			menu->AddItem(new BMenuItem(
				B_TRANSLATE("Edit icon" B_UTF8_ELLIPSIS),
				new BMessage(kMsgEditIcon)));
		} else {
			menu->AddItem(new BMenuItem(
				B_TRANSLATE("Add icon" B_UTF8_ELLIPSIS),
				new BMessage(kMsgAddIcon)));
		}

		BMenuItem* item = new BMenuItem(
			B_TRANSLATE("Remove icon"), new BMessage(kMsgRemoveIcon));
		if (!hasIcon)
			item->SetEnabled(false);

		menu->AddItem(item);
		menu->SetTargetForItems(fTarget);

		menu->Go(where, true, false, true);
	}
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:58,代码来源:IconView.cpp

示例11: SearchBarTextControl

MainWindow::MainWindow()
	:
	BWindow(BRect(0, 0, 300, 400), "Caya", B_TITLED_WINDOW, 0),
	fWorkspaceChanged(false)
{
	fStatusView = new StatusView("statusView");

	SearchBarTextControl* searchBox = 
		new SearchBarTextControl(new BMessage(kSearchContact));

	fListView = new RosterListView("buddyView");
	fListView->SetInvocationMessage(new BMessage(CAYA_OPEN_CHAT_WINDOW));
	BScrollView* scrollView = new BScrollView("scrollview", fListView,
		B_WILL_DRAW, false, true);

	// Wrench menu
	BPopUpMenu* wrenchMenu = new BPopUpMenu("Wrench");
	(void)wrenchMenu->AddItem(new BMenuItem("About" B_UTF8_ELLIPSIS,
		new BMessage(B_ABOUT_REQUESTED)));
	(void)wrenchMenu->AddItem(new BSeparatorItem());
	(void)wrenchMenu->AddItem(new BMenuItem("Preferences" B_UTF8_ELLIPSIS,
		new BMessage(CAYA_SHOW_SETTINGS)));
	(void)wrenchMenu->AddItem(new BSeparatorItem());
	(void)wrenchMenu->AddItem(new BMenuItem("Quit",
		new BMessage(B_QUIT_REQUESTED)));
	wrenchMenu->SetTargetForItems(this);

	// Tool icon
	BResources* res = CayaResources();
	BBitmap* toolIcon = IconFromResources(res, kToolIcon);
	delete res;

	// Wrench tool button
	ToolButton* wrench = new ToolButton(NULL, NULL);
	wrench->SetBitmap(toolIcon);
	wrench->SetMenu(wrenchMenu);

	SetLayout(new BGridLayout(1, 2));
	AddChild(BGridLayoutBuilder(1, 2)
		.Add(searchBox, 0, 0)
		.Add(wrench, 1, 0)
		.Add(scrollView, 0, 1, 2)
		.Add(fStatusView, 0, 2, 2)
		.SetInsets(5, 5, 5, 10)
	);

	AddShortcut('a', B_COMMAND_KEY, new BMessage(B_ABOUT_REQUESTED));
	MoveTo(BAlert::AlertPosition(Bounds().Width(), Bounds().Height() / 2));

	// Filter messages using Server
	fServer = new Server();
	AddFilter(fServer);

	CenterOnScreen();

	//TODO check for errors here
	ReplicantStatusView::InstallReplicant();
}
开发者ID:ModeenF,项目名称:Caya,代码行数:58,代码来源:MainWindow.cpp

示例12: BPopUpMenu

// DisplayPopupMenu
bool
SplitManipulator::DisplayPopupMenu(BPoint where)
{
	BPopUpMenu* menu = new BPopUpMenu("item popup", false, false);

	BMessage* message;
	BMenuItem* item;

	bool separator = false;

	if (fItem->HasVideo()) {
		message = new BMessage(MSG_SET_VIDEO_MUTED);
		message->AddPointer("item", fItem);
		item = new BMenuItem("Enabled Video", message);
		item->SetMarked(!fItem->IsVideoMuted());
		menu->AddItem(item);
		separator = true;
	}

	if (fItem->HasAudio()) {
		message = new BMessage(MSG_SET_AUDIO_MUTED);
		message->AddPointer("item", fItem);
		item = new BMenuItem("Enabled Audio", message);
		item->SetMarked(!fItem->IsAudioMuted());
		menu->AddItem(item);
		separator = true;
	}

	if (separator)
		menu->AddSeparatorItem();

	BMenuItem* selectClipItem = NULL;
	if (ClipPlaylistItem* clipItem = dynamic_cast<ClipPlaylistItem*>(fItem)) {
		message = new BMessage(MSG_SELECT_AND_SHOW_CLIP);
		message->AddPointer("clip", clipItem->Clip());
		selectClipItem = new BMenuItem("Select Clip", message);
		menu->AddItem(selectClipItem);
	} else
		separator = false;

	if (separator)
		menu->AddSeparatorItem();

	message = new BMessage(MSG_REMOVE_ITEM);
	message->AddPointer("item", fItem);
	item = new BMenuItem("Remove Clip", message);
	menu->AddItem(item);

	menu->SetTargetForItems(fView);
	if (selectClipItem)
		selectClipItem->SetTarget(fView->Window());

	show_popup_menu(menu, where, fView, false);

	return true;
}
开发者ID:stippi,项目名称:Clockwerk,代码行数:57,代码来源:SplitManipulator.cpp

示例13: BMessage

void
URLInputGroup::URLTextView::MouseDown(BPoint where)
{
	bool wasFocus = IsFocus();
	if (!wasFocus)
		MakeFocus(true);

	int32 buttons;
	if (Window()->CurrentMessage()->FindInt32("buttons", &buttons) != B_OK)
		buttons = B_PRIMARY_MOUSE_BUTTON;

	if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
		// Display context menu
		int32 selectionStart;
		int32 selectionEnd;
		GetSelection(&selectionStart, &selectionEnd);
		bool canCutOrCopy = selectionEnd > selectionStart;

		bool canPaste = false;
		if (be_clipboard->Lock()) {
			if (BMessage* data = be_clipboard->Data())
				canPaste = data->HasData("text/plain", B_MIME_TYPE);
			be_clipboard->Unlock();
		}

		BMenuItem* cutItem = new BMenuItem(B_TRANSLATE("Cut"),
			new BMessage(B_CUT));
		BMenuItem* copyItem = new BMenuItem(B_TRANSLATE("Copy"),
			new BMessage(B_COPY));
		BMenuItem* pasteItem = new BMenuItem(B_TRANSLATE("Paste"),
			new BMessage(B_PASTE));
		BMenuItem* clearItem = new BMenuItem(B_TRANSLATE("Clear"),
			new BMessage(MSG_CLEAR));
		cutItem->SetEnabled(canCutOrCopy);
		copyItem->SetEnabled(canCutOrCopy);
		pasteItem->SetEnabled(canPaste);
		clearItem->SetEnabled(strlen(Text()) > 0);

		BPopUpMenu* menu = new BPopUpMenu("url context");
		menu->AddItem(cutItem);
		menu->AddItem(copyItem);
		menu->AddItem(pasteItem);
		menu->AddItem(clearItem);

		menu->SetTargetForItems(this);
		menu->Go(ConvertToScreen(where), true, true, true);
		return;
	}

	// Only pass through to base class if we already have focus.
	if (!wasFocus)
		return;

	BTextView::MouseDown(where);
}
开发者ID:MaddTheSane,项目名称:haiku,代码行数:55,代码来源:URLInputGroup.cpp

示例14: BMessage

void
MediaReplicant::MouseDown(BPoint point)
{
	int32 buttons = B_PRIMARY_MOUSE_BUTTON;
	if (Looper() != NULL && Looper()->CurrentMessage() != NULL)
		Looper()->CurrentMessage()->FindInt32("buttons", &buttons);

	BPoint where = ConvertToScreen(point);

	if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
		BPopUpMenu* menu = new BPopUpMenu("", false, false);
		menu->SetFont(be_plain_font);

		menu->AddItem(new BMenuItem(
			B_TRANSLATE("Media preferences" B_UTF8_ELLIPSIS),
			new BMessage(kMsgOpenMediaSettings)));
		menu->AddItem(new BMenuItem(
			B_TRANSLATE("Sound preferences" B_UTF8_ELLIPSIS),
			new BMessage(kMsgOpenSoundSettings)));

		menu->AddSeparatorItem();

		menu->AddItem(new BMenuItem(B_TRANSLATE("Open MediaPlayer"),
			new BMessage(kMsgOpenMediaPlayer)));

		menu->AddSeparatorItem();

		BMenu* subMenu = new BMenu(B_TRANSLATE("Options"));
		menu->AddItem(subMenu);

		BMenuItem* item = new BMenuItem(B_TRANSLATE("Control physical output"),
			new BMessage(kMsgVolumeWhich));
		item->SetMarked(fVolumeWhich == VOLUME_USE_PHYS_OUTPUT);
		subMenu->AddItem(item);

		item = new BMenuItem(B_TRANSLATE("Beep"),
			new BMessage(kMsgToggleBeep));
		item->SetMarked(!fDontBeep);
		subMenu->AddItem(item);

		menu->SetTargetForItems(this);
		subMenu->SetTargetForItems(this);

		menu->Go(where, true, true, BRect(where - BPoint(4, 4),
			where + BPoint(4, 4)));
	} else {
		// Show VolumeWindow
		fVolumeSlider = new VolumeWindow(BRect(where.x, where.y,
			where.x + 207, where.y + 19), fDontBeep, fVolumeWhich);
		fVolumeSlider->Show();
	}
}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:52,代码来源:MediaReplicant.cpp

示例15: BMessage

void
NetPulseView::MouseDown(BPoint where)
{
	int32 buttons;
	int32 clicks;
	if (Window()->CurrentMessage()->FindInt32("buttons", &buttons) != B_OK
		|| Window()->CurrentMessage()->FindInt32("clicks", &clicks) != B_OK) {
		return;
	}

	if (buttons == B_SECONDARY_MOUSE_BUTTON) {	
		BPopUpMenu* popUpMenu = new BPopUpMenu("NetPulseMenu");

		popUpMenu->AddItem(new BMenuItem("Connect",
			new BMessage(kMsgConnect)));
		popUpMenu->AddItem(new BMenuItem("Disconnect",
			new BMessage(kMsgDisconnect)));
		popUpMenu->AddSeparatorItem();

		popUpMenu->AddItem(new BMenuItem("Statistics...",
			new BMessage(kMsgStatistics)));
		popUpMenu->AddSeparatorItem();

		uint32 cookie = 0;
		BNetworkInterface interface;
		BNetworkRoster& roster = BNetworkRoster::Default();
		while (roster.GetNextInterface(&cookie, interface) == B_OK) {
			const char* name = interface.Name();
			if (strncmp(name, "loop", 4) != 0) {
				BMenuItem* menuItem = new BMenuItem(name,
					new BMessage(kMsgChangeInterface + cookie));
				menuItem->SetMarked(cookie == fCookie);
				popUpMenu->AddItem(menuItem);
			}
		}

		popUpMenu->AddSeparatorItem();
		popUpMenu->AddItem(new BMenuItem("Quit", new BMessage(kMsgQuit)));
		popUpMenu->SetTargetForItems(this);

		popUpMenu->FindItem(kMsgConnect)->SetEnabled(!fEnable && fCookie != 0);
		popUpMenu->FindItem(kMsgDisconnect)->SetEnabled(fEnable && fCookie != 0);
		popUpMenu->FindItem(kMsgStatistics)->SetEnabled(fEnable && fCookie != 0);

		popUpMenu->Go(ConvertToScreen(BPoint(0, 0)), true, false, false);
		delete popUpMenu;
	} else if (buttons == B_PRIMARY_MOUSE_BUTTON && clicks == 2)
		be_roster->Launch("application/x-vnd.Haiku-Network");
}
开发者ID:HaikuArchives,项目名称:NetPulse,代码行数:49,代码来源:NetPulseView.cpp


注:本文中的BPopUpMenu::SetTargetForItems方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。