Commit adc9e882 authored by DailyShana's avatar DailyShana

fix on linux

compile, input char, clipboard
parent d38e1fdf
...@@ -156,7 +156,7 @@ set (INCLUDE_FILES_GUI ...@@ -156,7 +156,7 @@ set (INCLUDE_FILES_GUI
"include/EMessageBoxFlags.h" "include/EMessageBoxFlags.h"
"include/ICursorControl.h" "include/ICursorControl.h"
"include/IGUIButton.h" "include/IGUIButton.h"
"include/IGUICheckbox.h" "include/IGUICheckBox.h"
"include/IGUIComboBox.h" "include/IGUIComboBox.h"
"include/IGUIContextMenu.h" "include/IGUIContextMenu.h"
"include/IGUIEditBox.h" "include/IGUIEditBox.h"
...@@ -827,7 +827,7 @@ set (SRC_FILES_GUI ...@@ -827,7 +827,7 @@ set (SRC_FILES_GUI
"src/BuiltInFont.h" "src/BuiltInFont.h"
"src/CDefaultGUIElementFactory.h" "src/CDefaultGUIElementFactory.h"
"src/CGUIButton.h" "src/CGUIButton.h"
"src/CGUICheckbox.h" "src/CGUICheckBox.h"
"src/CGUIColorSelectDialog.h" "src/CGUIColorSelectDialog.h"
"src/CGUIComboBox.h" "src/CGUIComboBox.h"
"src/CGUIContextMenu.h" "src/CGUIContextMenu.h"
...@@ -855,7 +855,7 @@ set (SRC_FILES_GUI ...@@ -855,7 +855,7 @@ set (SRC_FILES_GUI
"src/CGUIWindow.h" "src/CGUIWindow.h"
"src/CDefaultGUIElementFactory.cpp" "src/CDefaultGUIElementFactory.cpp"
"src/CGUIButton.cpp" "src/CGUIButton.cpp"
"src/CGUICheckbox.cpp" "src/CGUICheckBox.cpp"
"src/CGUIColorSelectDialog.cpp" "src/CGUIColorSelectDialog.cpp"
"src/CGUIComboBox.cpp" "src/CGUIComboBox.cpp"
"src/CGUIContextMenu.cpp" "src/CGUIContextMenu.cpp"
...@@ -898,12 +898,14 @@ include_directories ( include src/zlib src/jpeglib src/libpng ) ...@@ -898,12 +898,14 @@ include_directories ( include src/zlib src/jpeglib src/libpng )
add_definitions ("-D_IRR_STATIC_LIB_") add_definitions ("-D_IRR_STATIC_LIB_")
if (CMAKE_C_COMPILER MATCHES "cc")
add_definitions ("-U__STRICT_ANSI__")
endif ()
if (WIN32) if (WIN32)
include_directories ( $ENV{DXSDK_DIR}/include ) include_directories ( $ENV{DXSDK_DIR}/include )
if (MSVC) if (MSVC)
add_definitions ("-DIRRLICHT_FAST_MATH") add_definitions ("-DIRRLICHT_FAST_MATH")
elseif (MINGW)
add_definitions ("-U__STRICT_ANSI__")
endif () endif ()
endif () endif ()
......
...@@ -29,8 +29,7 @@ public: ...@@ -29,8 +29,7 @@ public:
virtual void copyToClipboard(const wchar_t* text) const = 0; virtual void copyToClipboard(const wchar_t* text) const = 0;
//! Get text from the clipboard //! Get text from the clipboard
/** \return Returns 0 if no string is in there. */ virtual const core::stringw getTextFromClipboard() const = 0;
virtual const wchar_t* getTextFromClipboard() const = 0;
//! Get the processor speed in megahertz //! Get the processor speed in megahertz
/** \param MHz The integer variable to store the speed in. /** \param MHz The integer variable to store the speed in.
......
...@@ -326,11 +326,9 @@ bool CGUIEditBox::processKey(const SEvent& event) ...@@ -326,11 +326,9 @@ bool CGUIEditBox::processKey(const SEvent& event)
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;
// add new character // add new character
const wchar_t* p = Operator->getTextFromClipboard(); const irr::core::stringw widep = Operator->getTextFromClipboard();
if (p) if (!widep.empty())
{ {
irr::core::stringw widep(p);
if (MarkBegin == MarkEnd) if (MarkBegin == MarkEnd)
{ {
// insert text // insert text
......
...@@ -1042,9 +1042,13 @@ bool CIrrDeviceLinux::run() ...@@ -1042,9 +1042,13 @@ bool CIrrDeviceLinux::run()
char buf[8]={0}; char buf[8]={0};
XLookupString(&event.xkey, buf, sizeof(buf), &mp.X11Key, NULL); XLookupString(&event.xkey, buf, sizeof(buf), &mp.X11Key, NULL);
irrevent.EventType = irr::EET_CHAR_INPUT_EVENT; if(event.type == KeyPress
irrevent.CharInput.Char = irr::core::stringw(buf).c_str(); && !(buf[0] < 32 || buf[0] > 126 && buf[0] < 160))
postEventFromUser(irrevent); {
irrevent.EventType = irr::EET_CHAR_INPUT_EVENT;
irrevent.CharInput.Char = irr::core::stringw(buf).c_str()[0];
postEventFromUser(irrevent);
}
irrevent.EventType = irr::EET_KEY_INPUT_EVENT; irrevent.EventType = irr::EET_KEY_INPUT_EVENT;
irrevent.KeyInput.PressedDown = (event.type == KeyPress); irrevent.KeyInput.PressedDown = (event.type == KeyPress);
...@@ -1877,7 +1881,7 @@ const c8* CIrrDeviceLinux::getTextFromClipboard() const ...@@ -1877,7 +1881,7 @@ const c8* CIrrDeviceLinux::getTextFromClipboard() const
Clipboard = ""; Clipboard = "";
if (ownerWindow != None ) if (ownerWindow != None )
{ {
XConvertSelection (display, X_ATOM_CLIPBOARD, XA_STRING, XA_PRIMARY, ownerWindow, CurrentTime); XConvertSelection (display, X_ATOM_CLIPBOARD, X_ATOM_UTF8_STRING, XA_PRIMARY, ownerWindow, CurrentTime);
XFlush (display); XFlush (display);
// check for data // check for data
......
...@@ -92,14 +92,13 @@ void COSOperator::copyToClipboard(const wchar_t* text) const ...@@ -92,14 +92,13 @@ void COSOperator::copyToClipboard(const wchar_t* text) const
//! gets text from the clipboard //! gets text from the clipboard
//! \return Returns 0 if no string is in there. const core::stringw COSOperator::getTextFromClipboard() const
const wchar_t* COSOperator::getTextFromClipboard() const
{ {
#if defined(_IRR_XBOX_PLATFORM_) #if defined(_IRR_XBOX_PLATFORM_)
return 0; return 0;
#elif defined(_IRR_WINDOWS_API_) #elif defined(_IRR_WINDOWS_API_)
if (!OpenClipboard(NULL)) if (!OpenClipboard(NULL))
return 0; return L"";
wchar_t * buffer = 0; wchar_t * buffer = 0;
...@@ -110,11 +109,11 @@ const wchar_t* COSOperator::getTextFromClipboard() const ...@@ -110,11 +109,11 @@ const wchar_t* COSOperator::getTextFromClipboard() const
return buffer; return buffer;
#elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_) #elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
return irr::core::stringw(OSXCopyFromClipboard()).c_str(); return irr::core::stringw(OSXCopyFromClipboard());
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) #elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
if ( IrrDeviceLinux ) if ( IrrDeviceLinux )
return irr::core::stringw(IrrDeviceLinux->getTextFromClipboard()).c_str(); return irr::core::stringw(IrrDeviceLinux->getTextFromClipboard());
return 0; return 0;
#else #else
......
...@@ -30,8 +30,7 @@ public: ...@@ -30,8 +30,7 @@ public:
virtual void copyToClipboard(const wchar_t* text) const; virtual void copyToClipboard(const wchar_t* text) const;
//! gets text from the clipboard //! gets text from the clipboard
//! \return Returns 0 if no string is in there. virtual const core::stringw getTextFromClipboard() const;
virtual const wchar_t* getTextFromClipboard() const;
//! gets the processor speed in megahertz //! gets the processor speed in megahertz
//! \param Mhz: //! \param Mhz:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment