Ejemplo n.º 1
0
nsresult
EditorEventListener::Drop(nsIDOMDragEvent* aDragEvent)
{
  NS_ENSURE_TRUE(aDragEvent, NS_OK);

  CleanupDragDropCaret();

  bool defaultPrevented;
  aDragEvent->AsEvent()->GetDefaultPrevented(&defaultPrevented);
  if (defaultPrevented) {
    return NS_OK;
  }

  nsCOMPtr<nsIDOMNode> parent;
  aDragEvent->GetRangeParent(getter_AddRefs(parent));
  nsCOMPtr<nsIContent> dropParent = do_QueryInterface(parent);
  NS_ENSURE_TRUE(dropParent, NS_ERROR_FAILURE);

  if (!dropParent->IsEditable() || !CanDrop(aDragEvent)) {
    // was it because we're read-only?
    if ((mEditorBase->IsReadonly() || mEditorBase->IsDisabled()) &&
        !IsFileControlTextBox()) {
      // it was decided to "eat" the event as this is the "least surprise"
      // since someone else handling it might be unintentional and the
      // user could probably re-drag to be not over the disabled/readonly
      // editfields if that is what is desired.
      return aDragEvent->AsEvent()->StopPropagation();
    }
    return NS_OK;
  }

  aDragEvent->AsEvent()->StopPropagation();
  aDragEvent->AsEvent()->PreventDefault();
  return mEditorBase->InsertFromDrop(aDragEvent->AsEvent());
}
Ejemplo n.º 2
0
void VoiceCall::Drop()
{
	if (!CanDrop())
		return;

	RemoveNotifications();

	CallProtoService(module->name, PS_VOICE_DROPCALL, (WPARAM) id, 0);
}
Ejemplo n.º 3
0
	void CWeaponDODBase::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
	{
		if ( CanDrop() == false )
			return;

		CDODPlayer *pPlayer = ToDODPlayer( pActivator );

		if ( pPlayer )
		{
			pPlayer->PickUpWeapon( this );
		}         
	}
Ejemplo n.º 4
0
//
//    Can only drop a card onto suit stack if it is same suit, and 1 higher
//
bool CARDLIBPROC SuitStackDropProc(CardRegion &stackobj, CardStack &dragcards)
{
    TRACE("ENTER SuitStackDropProc()\n");
    //only drop 1 card at a time
    if(dragcards.NumCards() != 1)
    {
        TRACE("EXIT SuitStackDropProc()\n");
        return false;
    }

    bool b = CanDrop(stackobj, dragcards[0]);
    TRACE("EXIT SuitStackDropProc()\n");
    return b;
}
Ejemplo n.º 5
0
//
//    Find the suit-stack that can accept the specified card
//
CardRegion *FindSuitStackFromCard(Card card)
{
    TRACE("ENTER FindSuitStackFromCard()\n");
    for(int i = 0; i < 4; i++)
    {
        if(CanDrop(*pSuitStack[i], card))
        {
            TRACE("EXIT FindSuitStackFromCard()\n");
            return pSuitStack[i];
        }
    }

    TRACE("EXIT FindSuitStackFromCard()\n");
    return 0;
}
Ejemplo n.º 6
0
Archivo: give.c Proyecto: Elohim/FGmud
mixed direct_give_obj_to_liv(object what, object target){
    mixed tmp;

    if( environment() != this_player() ){
        return "#You cannot give what is not yours.";
    }
    tmp = CanDrop(this_player());
    if( tmp != 1 ){
        return (tmp || "#You can't drop " + GetDefiniteShort() + ".");
    }
    if(target && objectp(target)){
        tmp = target->CanCarry(GetMass());
        if( tmp != 1 ){
            return capitalize(this_object()->GetDefiniteShort()) + " is too heavy.";
        }
    }
    return 1;
}
Ejemplo n.º 7
0
nsresult
EditorEventListener::DragOver(nsIDOMDragEvent* aDragEvent)
{
  NS_ENSURE_TRUE(aDragEvent, NS_OK);

  nsCOMPtr<nsIDOMNode> parent;
  bool defaultPrevented;
  aDragEvent->AsEvent()->GetDefaultPrevented(&defaultPrevented);
  if (defaultPrevented) {
    return NS_OK;
  }

  aDragEvent->GetRangeParent(getter_AddRefs(parent));
  nsCOMPtr<nsIContent> dropParent = do_QueryInterface(parent);
  NS_ENSURE_TRUE(dropParent, NS_ERROR_FAILURE);

  if (dropParent->IsEditable() && CanDrop(aDragEvent)) {
    aDragEvent->AsEvent()->PreventDefault(); // consumed

    if (!mCaret) {
      return NS_OK;
    }

    int32_t offset = 0;
    nsresult rv = aDragEvent->GetRangeOffset(&offset);
    NS_ENSURE_SUCCESS(rv, rv);

    mCaret->SetVisible(true);
    mCaret->SetCaretPosition(parent, offset);

    return NS_OK;
  }

  if (!IsFileControlTextBox()) {
    // This is needed when dropping on an input, to prevent the editor for
    // the editable parent from receiving the event.
    aDragEvent->AsEvent()->StopPropagation();
  }

  if (mCaret) {
    mCaret->SetVisible(false);
  }
  return NS_OK;
}
Ejemplo n.º 8
0
Archivo: give.c Proyecto: Elohim/FGmud
mixed indirect_give_liv_obj(object target){
    mixed tmp;

    if(!target){
        return "#That doesn't seem to be here.";
    }
    if( environment() != this_player() ){
        return "#You cannot give what is not yours.";
    }
    tmp = CanDrop(this_player());
    if( tmp != 1 ){
        return (tmp || "You can't drop " + GetDefiniteShort() + ".");
    }
    tmp = target->CanCarry(GetMass());
    if( tmp != 1 ){
        return (tmp || capitalize(GetDefiniteShort()) + " is too heavy.");
    }
    return 1;
}