void ChatPanel::OnPaste(wxClipboardTextEvent& event)
{
	// Read some text
	if (wxTheClipboard->Open()) {
		wxTextDataObject data;
		if (wxTheClipboard->GetData(data)) {
			wxString converted = data.GetText();
			converted.Replace(_T("\r\n"), _T("\n"));
			converted.Replace(_T("\r"), _T("\n"));
			m_say_text->WriteText(converted);
		} else
			event.Skip();
	} else
		event.Skip();
	wxTheClipboard->Close();
}
Exemple #2
0
void NumValidatorBase::OnPaste(wxClipboardTextEvent& event)
{
   event.Skip(false);

   wxTextEntry * const control = GetTextEntry();
   if ( !control )
   {
      return;
   }

   wxClipboardLocker cb;
//    if (!wxClipboard::Get()->IsSupported(wxDataFormat(wxDF_TEXT)))
   if (!wxClipboard::Get()->IsSupported(wxDF_TEXT))
   {
      return;
   }

   wxTextDataObject data;
   if (!wxClipboard::Get()->GetData( data ))
   {
      return;
   }

   wxString toPaste = data.GetText();
   wxString val;
   int pos;
   GetCurrentValueAndInsertionPoint(val, pos);

   for (size_t i = 0, cnt = toPaste.Length(); i < cnt; i++)
   {
      const wxChar ch = toPaste[i];

      // Check if this character is allowed in the current state.
      if ( IsCharOk(val, pos, ch) )
      {
         val = GetValueAfterInsertingChar(val, pos++, ch);
      }
      else if ( !wxValidator::IsSilent() )
      {
               wxBell();
      }
   }

   // When we change the control value below, its "modified" status is reset
   // so we need to explicitly keep it marked as modified if it was so in the
   // first place.
   //
   // Notice that only wxTextCtrl (and not wxTextEntry) has
   // IsModified()/MarkDirty() methods hence the need for dynamic cast.
   wxTextCtrl * const text = wxDynamicCast(m_validatorWindow, wxTextCtrl);
   const bool wasModified = text ? text->IsModified() : false;

   // Use SetValue because effect still needs EVT_TEXT (bug 1357)
   control->SetValue(NormalizeString(val));

   if ( wasModified )
   {
      text->MarkDirty();
   }
}
Exemple #3
0
void PositionCtrl::OnClipboardText(wxClipboardTextEvent& evt)
{
	Position position;
	if(posFromClipboard(position.x, position.y, position.z)) {
		x_field->SetIntValue(position.x);
		y_field->SetIntValue(position.y);
		z_field->SetIntValue(position.z);
	} else {
		evt.Skip();
	}
}