Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
deprecated-irrlicht-mac
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
deprecated-irrlicht-mac
Commits
f758fb54
Commit
f758fb54
authored
Mar 25, 2019
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
patch files
parent
d0d04c32
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
3941 additions
and
3843 deletions
+3941
-3843
source/Irrlicht/CGUIEditBox.cpp
source/Irrlicht/CGUIEditBox.cpp
+1568
-1564
source/Irrlicht/MacOSX/AppDelegate.h
source/Irrlicht/MacOSX/AppDelegate.h
+24
-24
source/Irrlicht/MacOSX/AppDelegate.mm
source/Irrlicht/MacOSX/AppDelegate.mm
+103
-79
source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
+253
-251
source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
+1957
-1889
source/Irrlicht/MacOSX/OSXClipboard.mm
source/Irrlicht/MacOSX/OSXClipboard.mm
+36
-36
No files found.
source/Irrlicht/CGUIEditBox.cpp
View file @
f758fb54
...
...
@@ -287,9 +287,11 @@ bool CGUIEditBox::processKey(const SEvent& event)
const
s32
realmbgn
=
MarkBegin
<
MarkEnd
?
MarkBegin
:
MarkEnd
;
const
s32
realmend
=
MarkBegin
<
MarkEnd
?
MarkEnd
:
MarkBegin
;
core
::
stringc
s
;
s
=
Text
.
subString
(
realmbgn
,
realmend
-
realmbgn
).
c_str
();
Operator
->
copyToClipboard
(
s
.
c_str
());
const
int
max_char_size
=
sizeof
(
wchar_t
)
*
3
/
2
;
int
max_size
=
(
realmend
-
realmbgn
)
*
max_char_size
+
1
;
c8
*
s
=
new
char
[
max_size
];
wcstombs
(
s
,
Text
.
subString
(
realmbgn
,
realmend
-
realmbgn
).
c_str
(),
max_size
);
Operator
->
copyToClipboard
(
s
);
}
break
;
case
KEY_KEY_X
:
...
...
@@ -300,9 +302,11 @@ bool CGUIEditBox::processKey(const SEvent& event)
const
s32
realmend
=
MarkBegin
<
MarkEnd
?
MarkEnd
:
MarkBegin
;
// copy
core
::
stringc
sc
;
sc
=
Text
.
subString
(
realmbgn
,
realmend
-
realmbgn
).
c_str
();
Operator
->
copyToClipboard
(
sc
.
c_str
());
const
int
max_char_size
=
sizeof
(
wchar_t
)
*
3
/
2
;
int
max_size
=
(
realmend
-
realmbgn
)
*
max_char_size
+
1
;
c8
*
s
=
new
char
[
max_size
];
wcstombs
(
s
,
Text
.
subString
(
realmbgn
,
realmend
-
realmbgn
).
c_str
(),
max_size
);
Operator
->
copyToClipboard
(
s
);
if
(
isEnabled
())
{
...
...
source/Irrlicht/MacOSX/AppDelegate.h
View file @
f758fb54
...
...
@@ -10,7 +10,7 @@
#import <Cocoa/Cocoa.h>
#import "CIrrDeviceMacOSX.h"
@interface
AppDelegate
:
NS
Object
@interface
AppDelegate
:
NS
TextView
<
NSApplicationDelegate
>
{
BOOL
_quit
;
irr
::
CIrrDeviceMacOSX
*
_device
;
...
...
source/Irrlicht/MacOSX/AppDelegate.mm
View file @
f758fb54
...
...
@@ -74,6 +74,30 @@
return
(
_quit
);
}
-
(
void
)
keyDown
:(
NSEvent
*
)
event
{
[
self
interpretKeyEvents
:@[
event
]];
}
-
(
void
)
insertText
:(
id
)
string
{
[
self
setString
:
@""
];
if
([
string
isKindOfClass
:[
NSAttributedString
class
]])
{
_device
->
handleInputEvent
([[
string
string
]
UTF8String
]);
}
else
{
_device
->
handleInputEvent
([
string
UTF8String
]);
}
}
-
(
void
)
doCommandBySelector
:(
SEL
)
selector
{
_device
->
processKeyEvent
();
}
@end
#endif // _IRR_COMPILE_WITH_OSX_DEVICE_
source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
View file @
f758fb54
...
...
@@ -95,6 +95,8 @@ namespace irr
void
setMouseLocation
(
int
x
,
int
y
);
void
setResize
(
int
width
,
int
height
);
void
setCursorVisible
(
bool
visible
);
void
handleInputEvent
(
const
char
*
str
);
void
processKeyEvent
();
private:
...
...
source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
View file @
f758fb54
...
...
@@ -496,7 +496,7 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
{
[[
NSAutoreleasePool
alloc
]
init
];
[
NSApplication
sharedApplication
];
[
NSApp
setDelegate
:
(
id
<
NSFileManagerDelegate
>
)[[[
AppDelegate
alloc
]
initWithDevice
:
this
]
autorelease
]];
[
NSApp
setDelegate
:
[[[[
AppDelegate
alloc
]
initWithDevice
:
this
]
initWithFrame
:
NSZeroRect
]
autorelease
]];
[
NSBundle
loadNibNamed
:
@"MainMenu"
owner
:[
NSApp
delegate
]];
[
NSApp
finishLaunching
];
}
...
...
@@ -592,6 +592,38 @@ void CIrrDeviceMacOSX::closeDevice()
CGLContext
=
NULL
;
}
void
CIrrDeviceMacOSX
::
processKeyEvent
()
{
irr
::
SEvent
ievent
;
NSEvent
*
event
=
[[
NSApplication
sharedApplication
]
currentEvent
];
postKeyEvent
(
event
,
ievent
,
true
);
}
void
CIrrDeviceMacOSX
::
handleInputEvent
(
const
char
*
cStr
)
{
SEvent
ievent
;
// TODO: we should have such a function in core::string
size_t
lenOld
=
strlen
(
cStr
);
wchar_t
*
ws
=
new
wchar_t
[
lenOld
+
1
];
size_t
len
=
mbstowcs
(
ws
,
cStr
,
lenOld
);
ws
[
len
]
=
0
;
irr
::
core
::
stringw
widep
(
ws
);
delete
[]
ws
;
ievent
.
EventType
=
irr
::
EET_KEY_INPUT_EVENT
;
ievent
.
KeyInput
.
Key
=
(
irr
::
EKEY_CODE
)
0
;
ievent
.
KeyInput
.
PressedDown
=
true
;
ievent
.
KeyInput
.
Shift
=
false
;
ievent
.
KeyInput
.
Control
=
false
;
for
(
int
i
=
0
;
i
<
widep
.
size
();
++
i
)
{
ievent
.
KeyInput
.
Char
=
widep
[
i
];
postEventFromUser
(
ievent
);
}
}
bool
CIrrDeviceMacOSX
::
createWindow
()
{
CGDisplayErr
error
;
...
...
@@ -881,6 +913,8 @@ bool CIrrDeviceMacOSX::createWindow()
newSwapInterval
=
(
CreationParams
.
Vsync
)
?
1
:
0
;
CGLSetParameter
(
CGLContext
,
kCGLCPSwapInterval
,
&
newSwapInterval
);
}
[[
Window
contentView
]
addSubview
:(
AppDelegate
*
)[
NSApp
delegate
]];
}
return
(
result
);
...
...
@@ -971,6 +1005,33 @@ bool CIrrDeviceMacOSX::run()
os
::
Timer
::
tick
();
storeMouseLocation
();
auto
focusElement
=
getGUIEnvironment
()
->
getFocus
();
bool
editing
=
focusElement
&&
focusElement
->
getType
()
==
irr
::
gui
::
EGUIET_EDIT_BOX
;
if
(
!
editing
)
{
[
Window
makeFirstResponder
:
nil
];
}
else
{
auto
textView
=
(
NSTextView
*
)[
NSApp
delegate
];
auto
crect
=
focusElement
->
getAbsolutePosition
();
// ensure font height enough to fill the rect, otherwize ime window will overlaps the edit box
[
textView
setFont
:[
NSFont
userFontOfSize
:
crect
.
getHeight
()]];
// change origin from top left to bottom right
NSRect
rect
=
{
crect
.
UpperLeftCorner
.
X
,
[[
textView
superview
]
frame
].
size
.
height
-
crect
.
LowerRightCorner
.
Y
,
crect
.
getWidth
(),
crect
.
getHeight
(),
};
[
textView
setFrame
:
rect
];
// start to receive input events
[
Window
makeFirstResponder
:
textView
];
}
event
=
[
NSApp
nextEventMatchingMask
:
NSAnyEventMask
untilDate
:[
NSDate
distantPast
]
inMode
:
NSDefaultRunLoopMode
dequeue
:
YES
];
if
(
event
!=
nil
)
{
...
...
@@ -979,6 +1040,13 @@ bool CIrrDeviceMacOSX::run()
switch
([(
NSEvent
*
)
event
type
])
{
case
NSKeyDown
:
if
(
editing
)
{
// delegate to text edit control to handle text input
[
NSApp
sendEvent
:
event
];
break
;
}
postKeyEvent
(
event
,
ievent
,
true
);
break
;
...
...
@@ -1199,11 +1267,14 @@ void CIrrDeviceMacOSX::postKeyEvent(void *event,irr::SEvent &ievent,bool pressed
}
else
{
cStr
=
(
unsigned
char
*
)[
str
cStringUsingEncoding
:
NSWindowsCP1252StringEncoding
];
cStr
=
(
unsigned
char
*
)[
str
UTF8String
];
if
(
cStr
!=
NULL
&&
strlen
((
char
*
)
cStr
)
>
0
)
{
mchar
=
cStr
[
0
];
mkey
=
toupper
(
mchar
);
}
}
}
if
([(
NSEvent
*
)
event
modifierFlags
]
&
NSCommandKeyMask
)
{
if
(
mkey
==
'C'
||
mkey
==
'V'
||
mkey
==
'X'
)
...
...
@@ -1212,9 +1283,6 @@ void CIrrDeviceMacOSX::postKeyEvent(void *event,irr::SEvent &ievent,bool pressed
skipCommand
=
true
;
}
}
}
}
}
ievent
.
EventType
=
irr
::
EET_KEY_INPUT_EVENT
;
ievent
.
KeyInput
.
Key
=
(
irr
::
EKEY_CODE
)
mkey
;
...
...
source/Irrlicht/MacOSX/OSXClipboard.mm
View file @
f758fb54
...
...
@@ -13,7 +13,7 @@ void OSXCopyToClipboard(const char *text)
if
((
text
!=
NULL
)
&&
(
strlen
(
text
)
>
0
))
{
str
=
[
NSString
stringWith
CString
:
text
encoding
:
NSWindowsCP1252StringEncoding
];
str
=
[
NSString
stringWith
UTF8String
:
text
];
board
=
[
NSPasteboard
generalPasteboard
];
[
board
declareTypes
:[
NSArray
arrayWithObject
:
NSStringPboardType
]
owner
:
NSApp
];
[
board
setString
:
str
forType
:
NSStringPboardType
];
...
...
@@ -30,7 +30,7 @@ char* OSXCopyFromClipboard()
board
=
[
NSPasteboard
generalPasteboard
];
str
=
[
board
stringForType
:
NSStringPboardType
];
if
(
str
!=
nil
)
result
=
(
char
*
)[
str
cStringUsingEncoding
:
NSWindowsCP1252StringEncoding
];
result
=
(
char
*
)[
str
UTF8String
];
return
(
result
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment