Esempio n. 1
0
void ArpDocumentButton::MouseMoved(BPoint point, uint32 transit,
							 const BMessage* message)
{
	BMessage* curMsg = Window()->CurrentMessage();
	
	if( message ) {
		// Only update button when drag enters or leaves the view.
		if( transit != B_ENTERED_VIEW && transit != B_EXITED_VIEW ) return;
		
		BMessenger source;
		if( message->FindMessenger("ARP:source", &source) == B_OK ) {
			if( source == BMessenger(this) ) return;
		}
		bool newDropped = false;
		if( transit == B_ENTERED_VIEW ) {
			// Is this a message we can handle?
			bool control=false;
			if( curMsg ) {
				int32 modifiers=0;
				curMsg->FindInt32("modifiers",&modifiers);
				if( (modifiers&B_LEFT_CONTROL_KEY) != 0 ) control=true;
				ArpD(cdb << ADH << "Drag entered view, ctrl=" << control
							<< ", mouse move=" << *curMsg << endl);
			}
			if( control || GetDropRef(0,message) == B_OK
						|| GetDropAction(0,message) == B_OK ) {
				newDropped = true;
			}
		}
		if( newDropped != mDropped ) {
			ArpD(if( message ) cdb << "Dragged message: " << *message << endl);
			mDropped = newDropped;
			Invalidate();
		}
	}
//------------------------------------------------------------------------------
FReply FKismetFunctionDragDropAction::DroppedOnPanel(TSharedRef<SWidget> const& Panel, FVector2D ScreenPosition, FVector2D GraphPosition, UEdGraph& Graph)
{	
	FReply Reply = FReply::Unhandled();

	// The ActionNode set during construction points to the Graph, this is suitable for displaying the mouse decorator but needs to be more complete based on the current graph
	UBlueprintFunctionNodeSpawner* FunctionNodeSpawner = nullptr;
	FunctionNodeSpawner = GetDropAction(Graph);

	if (FunctionNodeSpawner)
	{
		FText CannotDropReason = FText::GetEmpty();
		if (!CanBeDroppedDelegate.IsBound() || CanBeDroppedDelegate.Execute(nullptr, GetHoveredGraph(), CannotDropReason))
		{
			UFunction const* Function = GetFunctionProperty();
			if ((Function != NULL) && UEdGraphSchema_K2::CanUserKismetCallFunction(Function))
			{
				AnalyticCallback.ExecuteIfBound();

				IBlueprintNodeBinder::FBindingSet Bindings;
				FunctionNodeSpawner->Invoke(&Graph, Bindings, GraphPosition);

				Reply = FReply::Handled();
			}
		}
	}

	return Reply;
}
Esempio n. 3
0
void ArpDocumentButton::MessageReceived(BMessage* message)
{
	if( !message ) return;
	
	ArpD(cdb << ADH << "ArpDocumentButton::MessageReceived: " << *message << endl);
	if( message->WasDropped() ) {
		ArpD(cdb << ADH << "This was a dropped message." << endl);
		mDropped = false;
		Invalidate();
		switch( message->what ) {
			case B_SIMPLE_DATA: {
				entry_ref ref;
				BMessage data;
				if( GetDropRef(&ref, message, mDropped) == B_OK ) {
					// Forward to target as an "open" action.
					ArpD(cdb << ADH << "Sending to target as B_REFS_RECEIVED."
								<< endl);
					BMessage openMsg(*message);
					openMsg.what = B_REFS_RECEIVED;
					Invoke(&openMsg);
				} else if( GetDropAction(&data, message, mDropped) == B_OK ) {
					// Only if we are not the one who sent the message...
					BMessenger source;
					if( message->FindMessenger("ARP:source", &source) == B_OK ) {
						if( source == BMessenger(this) ) return;
					}
					// Tell the sender what format we would like the data in, and
					// have it send the final reply containing that data to our
					// target.
					ArpD(cdb << ADH << "Replying with desired action: " << data
								<< endl);
					message->SendReply(&data, Messenger());
				}
			} break;
			default:
				ArpD(cdb << ADH << "Not a drop I understand." << endl);
				inherited::MessageReceived(message);
		}
		return;
	}
	
	// If this action is one of the allowed ones in our prototype, forward
	// it to the target handler.
	int32 action=0;
	int i;
	for( i=0; mDragPrototype.FindInt32("be:actions", i, &action)==B_OK; i++ ) {
		if( static_cast<type_code>(action) == message->what ) {
			ArpD(cdb << ADH << "Forwarding this action to target." << endl);
			// Forward message on to target, making that target's reply
			// go back to the originator.
			InvokeReply(message);
			//Messenger().SendMessage(message, message->ReturnAddress());
			//Invoke(message);
			return;
		}
	}
	
	// Forward any other data received to the target.  Using the official
	// drag and drop protocol, this should never happen -- we redirect the
	// data message directly to our target, when responding to the initial
	// drop.  However, just in case, we also catch data messages here.
	if( message->what == B_MIME_DATA ) {
		ArpD(cdb << ADH << "Forwarding this data to target." << endl);
		InvokeReply(message);
		return;
	}
	
	ArpD(cdb << ADH << "Not a message I understand." << endl);
	inherited::MessageReceived(message);
}