Example #1
0
void
NotifyList::MouseDown (BPoint myPoint)
{
  BMessage *msg (Window()->CurrentMessage());
  int32 selected (IndexOf (myPoint));
  if (selected >= 0)
  {
    BMessage *inputMsg (Window()->CurrentMessage());
    int32 mousebuttons (0),
          keymodifiers (0);
    
    NotifyListItem *item ((NotifyListItem *)ItemAt(selected));
    if (!item)
      return;
    
    inputMsg->FindInt32 ("buttons", &mousebuttons);
    inputMsg->FindInt32 ("modifiers", &keymodifiers);
    
    bigtime_t sysTime;
    msg->FindInt64 ("when", &sysTime);
    uint16 clicks = CheckClickCount (myPoint, fLastClick, sysTime, fLastClickTime, fClickCount) % 3;
    
    // slight kludge to make sure the expand/collapse triangles behave how they should
    // -- needed since OutlineListView's Expand/Collapse-related functions are not virtual
    if (mousebuttons == B_PRIMARY_MOUSE_BUTTON)
    {
      if (((clicks % 2) == 0) && item->GetState())
      {
        // react to double click by creating a new messageagent or selecting
        // an existing one (use /query logic in parsecmd)
        BString data (item->Text());
        data.Prepend ("/QUERY ");
        BMessage submitMsg (M_SUBMIT);
        submitMsg.AddString ("input", data.String());
        submitMsg.AddBool ("history", false);
        // don't clear in case user has something typed in text control
        submitMsg.AddBool ("clear", false);
        WindowListItem *winItem ((WindowListItem *)vision_app->pClientWin()->pWindowList()->ItemAt(
          vision_app->pClientWin()->pWindowList()->CurrentSelection()));
        if (winItem)
        {
          BMessenger msgr (winItem->pAgent());
          if (msgr.IsValid())
            msgr.SendMessage(&submitMsg);
        }
      }
      else
        Select (selected);
    }
    
    if ((keymodifiers & B_SHIFT_KEY)  == 0
    && (keymodifiers & B_OPTION_KEY)  == 0
    && (keymodifiers & B_COMMAND_KEY) == 0
    && (keymodifiers & B_CONTROL_KEY) == 0)
    {
      if (mousebuttons == B_SECONDARY_MOUSE_BUTTON)
      {
        if (item)
        {
          if(!item->IsSelected())
            Select (IndexOf (myPoint));

          BuildPopUp();

          fMyPopUp->Go (
            ConvertToScreen (myPoint),
            true,
            true,
            ConvertToScreen (ItemFrame (selected)),
            true);
        }
      }
    }
  }

}
Example #2
0
void
NamesView::MouseDown (BPoint myPoint)
{
	int32 selected (IndexOf (myPoint));
	bool handled (false);

	if (selected < 0)
	{
		DeselectAll();
		return;
	}

	BMessage *inputMsg (Window()->CurrentMessage());
	int32 mousebuttons (0),
				keymodifiers (0),
				mouseclicks (0);

	inputMsg->FindInt32 ("buttons", &mousebuttons);
	inputMsg->FindInt32 ("modifiers", &keymodifiers);
	inputMsg->FindInt32 ("clicks",	&mouseclicks);

	if (mouseclicks > 1
	&& CurrentSelection(1) <= 0
	&&	mousebuttons == B_PRIMARY_MOUSE_BUTTON
	&& (keymodifiers & B_SHIFT_KEY)	 == 0
	&& (keymodifiers & B_OPTION_KEY)	== 0
	&& (keymodifiers & B_COMMAND_KEY) == 0
	&& (keymodifiers & B_CONTROL_KEY) == 0)
	{
		// user double clicked

		BListItem *item (ItemAt (IndexOf(myPoint)));
		if (item && !item->IsSelected())
		{
			// "double" clicked away from another selection
			Select (IndexOf (myPoint), false);
			fCurrentindex = IndexOf (myPoint);
			fTracking = true;
		}
		else if (item && item->IsSelected())
		{
			// double clicking on a single item
			NameItem *myItem (reinterpret_cast<NameItem *>(item));
			BString theNick (myItem->Name());
			BMessage msg (M_OPEN_MSGAGENT);

			msg.AddString ("nick", theNick.String());
			reinterpret_cast<ChannelAgent *>(Parent()->Parent())->fMsgr.SendMessage (&msg);
		}

		handled = true;
	}

	if (mouseclicks == 1
	&&	CurrentSelection(1) <= 0
	&&	mousebuttons == B_PRIMARY_MOUSE_BUTTON
	&& (keymodifiers & B_SHIFT_KEY)	 == 0
	&& (keymodifiers & B_OPTION_KEY)	== 0
	&& (keymodifiers & B_COMMAND_KEY) == 0
	&& (keymodifiers & B_CONTROL_KEY) == 0)
	{
		// user single clicks
		BListItem *item (ItemAt (IndexOf(myPoint)));
		if (item && !item->IsSelected())
			Select (IndexOf (myPoint), false);

		fTracking = true;
		fCurrentindex = IndexOf (myPoint);
		handled = true;
	}

	if (mouseclicks >= 1
	&&	CurrentSelection(1) >= 0
	&&	mousebuttons == B_PRIMARY_MOUSE_BUTTON
	&& (keymodifiers & B_SHIFT_KEY)	 == 0
	&& (keymodifiers & B_OPTION_KEY)	== 0
	&& (keymodifiers & B_COMMAND_KEY) == 0
	&& (keymodifiers & B_CONTROL_KEY) == 0)
	{
		// user clicks on something in the middle of a sweep selection
		BListItem *item (ItemAt (IndexOf(myPoint)));
		if (item)
			Select (IndexOf (myPoint), false);

		fTracking = true;
		fCurrentindex = IndexOf (myPoint);
		handled = true;
	}

	if (mousebuttons == B_SECONDARY_MOUSE_BUTTON
	&& (keymodifiers & B_SHIFT_KEY)	 == 0
	&& (keymodifiers & B_OPTION_KEY)	== 0
	&& (keymodifiers & B_COMMAND_KEY) == 0
	&& (keymodifiers & B_CONTROL_KEY) == 0)
	{
		// user right clicks - display popup menu
		BListItem *item (ItemAt (IndexOf(myPoint)));
		if (item && !item->IsSelected())
			Select (IndexOf (myPoint), false);

		fMyPopUp->Go (
			ConvertToScreen (myPoint),
			true,
			false,
			ConvertToScreen (ItemFrame (selected)));
		handled = true;
	}
	if (mousebuttons == B_TERTIARY_MOUSE_BUTTON)
		BListView::MouseDown (myPoint);

	fLastSelected = selected;
	if (!handled)
		BListView::MouseDown (myPoint);
}