UIKeyCommand Arrow Key Input Not Working - cocoa-touch

I have other UIKeyCommand's working properly, however the arrow key (using UIKeyInput[Direction]Arrow constants) selectors are not getting called. Any suggestions will be much appreciated.
This is the code I am using to create an arrow key command:
UIKeyCommand(input: UIKeyInputRightArrow, modifierFlags: [], action: #selector(moveRight))
The moveRight selector is not getting called, nor are any arrow key selectors. Other UIKeyCommands, other than arrow keys, are working as expected.

Related

How can I detect mouse input on an Area2D node in Godot (viewport and shape_idx error)?

After testing out a few other engines I've settled into Godot for my game development learning process and have really appreciated the conciseness of GDScript, the node/inheritance structure, and the way observer events are covered by signals. I've been building knowledge through various tutorials and by reading through the documentation.
Somehow I'm struggling to solve the very fundamental task of detecting a mouseclick on a sprite. (Well, on a sprite's parent node, either a Node2D or an Area2D.)
My process has been this:
Create an Area2D node (called logo) with a Sprite child and a CollisionShape2D child
Assign a texture to the Sprite node, and change the x and y extent values of the CollisionShape2D node to match the size of the Sprite's texture
Connect the _on_logo_input_event(viewport, event, shape_idx) signal to the Area2D node's script (called logo.gd)
Use the following code:
func _on_logo_input_event(viewport, event, shape_idx):
if (event is InputEventMouseButton && event.pressed):
print("Logo clicked")
When I run the game I get nothing in the output after clicking, and see these errors:
The argument 'viewport' is never used in the function '_on_logo_input_event'. If this is intended, prefix it with an underscore: '_viewport'
The argument 'shape_idx' is never used in the function '_on_logo_input_event'. If this is intended, prefix it with an underscore: '_shape_idx'
I don't know how to address the parameters in this signal's function - My Area2D node is set to Pickable, and the logo Area2D node is a direct child to the game_window Node2D in the main scene. I can't figure out what is going wrong here, whether it's some project setting I need to change or an inspector attribute I need to set. Is there a better way to feed an input signal for a mouse click into a script?
I don't want to clutter stackoverflow with such a simple question but I've tried to do my due diligence and haven't been able to find this error message on any forums. I'd appreciate any help, thanks.
If the CollisionLayer of your Area2D is not empty, and input_pickable is on, then it is capable to get input. Either by connecting the input_event signal or by overriding _input_event.
If that is not working, the likely cause is that there is some Control/UI element that is stopping mouse events. They have a property called mouse_filter, which is set to Stop by default. You will need to find which Control is intercepting the input, and set its mouse_filter to Ignore.
By the way, these:
The argument 'viewport' is never used in the function '_on_logo_input_event'. If this is intended, prefix it with an underscore: '_viewport'
The argument 'shape_idx' is never used in the function '_on_logo_input_event'. If this is intended, prefix it with an underscore: '_shape_idx'
These are warnings. They are not the source of the problem. They tell what they say on the tin: you have some parameter that you are not using, and you can prefix its name with an underscore as a way to suppress the warning.
I would also recommend checking out this video:
https://www.youtube.com/watch?v=iSpWZzL2i1o
The main modification that he makes from what you have done is make a separate click event in Project > Project Settings > Input Map that maps to a left click. He can then reference that in the _on_Area2D_input_event.
extends Node2D
var selected = false
func _ready():
pass
func _on_Area2D_input_event(viewport, event, shape_idx):
if Input.is_action_just_pressed("click"):
selected = true
func _physics_process(delta):
if selected:
global_position = lerp(global_position, get_global_mouse_position(), 25 * delta)
func _input(event):
if event is InputEventMouseButton:
if event.button_index == BUTTON_LEFT and not event.pressed:
selected = false

How get key signal and not deleting it in wxTextCtrl

In initialize functions on my widgets i have:
Connect(wxEVT_TEXT_ENTER, wxCommandEventHandler(MyTextCtrl::EnterClick));
next I have
void MyTextCtrl::EnterClick(wxCommandEvent &event)
{ wxPrintf(wxT("enter\n"));}
trouble is with signal. the string is putting to console but on editor not working enter. How using specyfic key and no deleting it signal?
I would using key (making some procedure) but i would normal using it deeper
You use
event.Skip();
on the end of functions, nothing more

The data-source property isn't propagated from reagent to the render method of the React Native ListView component

I'm trying to render a React Native ListView in reagent.
I have the following snippet:
(def data-source
(React.ListView.DataSource. #js{:rowHasChanged (fn [a b] false)}))
(defn render-row []
[ui/view])
(def rows
(clj->js ["whoa", "hey"]))
(defn main-scene []
(fn []
[ui/list-view {:render-row render-row
:data-source (.cloneWithRows data-source rows)}]))
The above leads to "Failed propType: Required prop dataSource was not specified in ListView. Check the render method of app.ios.ui.main_scene." Which is followed by "Cannot read property 'rowIdentities' of undefined" as the data source is undefined inside the render method of the ListView.
My first guess was there was some special treatment of the "data-" attributes somewhere in the internals of either reagent/hiccup or whatever, but I couldn’t find a single clue to why the property is not propagated properly.
And, yep, (.cloneWithRows data-source rows) actually returns a valid ListViewDataSource object instance.
And then if I pass :data-source as :dataSource all I get is a puzzling "StaticRenderer.render(): A valid ReactComponent must be returned. You may have returned undefined, an array or some other invalid object."
I’m using react-native 0.18.1 and reagent 0.5.1 with re-frame 0.6.0. I have checked this with reagent 0.6.0-alpha and re-frame 0.7.0-alpha and got the same errors.
I've been digging this for several hours and I guess I need some help. Any hints/ideas to try to fix this, any references in the code to look at? Thanks a ton in advance.
Well, the first thing is the data source should be passed to the view as :dataSource and not as :data-source. The latter doesn’t work for whatever reason. As a side note, the render row method can both be passed as :render-row or :renderRow and it works both ways. Heh.
Secondly, the render-row function should return a React component and not an array. The latter would be okay if the array was later rendered by reagent, but the listview doesn’t do any kind of post-processing on the data it gets from render-row and merely tries to return that to React, which bails if it’s a plain clojure array.
So the above render-row function should be written as:
(defn render-row []
(r/as-element [ui/view]))
And then everything works fine. :)

Intercept Command+key with IMKit (or similar)

I was looking to intercept Command key combinations and thought that IMKit would be a good choice. By extending IMKInputController I can intercept most keys but it seems to ignore modified ones.
I've tried overriding
-(BOOL)inputText:(NSString*)string client:(id)sender;
and (alternatively)
-(BOOL)inputText:(NSString*)string
key:(NSInteger)keyCode
modifiers:(NSUInteger)flags
client:(id)sender;
but no luck; the methods just plain aren't called when the modifiers are applied. To be more specific the command and alt key don't get caught by the methods above. Simple modifiers like shift and ctrl work (and the modifier flags variable is set in the second method). Fire up Apple's sample application NumberInput to see for yourself.
Any suggestions? Am I on totally the wrong track?
Short answer:
Use handleEvent:client: and listen to the NSFlagsChanged event.
IMKInputController implements the IMKServerInput Protocol, which provides three alternatives to handle an event.
Key binding - using inputText:client: and didCommandBySelector:client:
Text data only - using inputText:key:modifiers:client:
Handle all events - using handleEvent:client:
Seems like you've only tried the top two. You can achieve the goal with the third option.
Try the following:
override recognizedEvents: (from IMKStateSetting Protocol)
- (NSUInteger)recognizedEvents:(id)sender
{
return NSKeyDownMask | NSFlagsChangedMask;
}
and use handleEvent:client:
-(BOOL)handleEvent:(NSEvent*)event client:(id)sender
{
NSLog(#"handling event: %#", event);
return false;
}
You can see the printout on every keydown and keyup of the modifiers in Console, including command and alt.

Invisible Marker in Eclipse

I've got an unusual error and I might be missing something - I've written a test plugin that should simply show an error marker on the first line of a file. I'm using this code, triggered from a button press
public void createMarkerForResource(IResource resource) throws CoreException {
HashMap map = new HashMap();
MarkerUtilities.setLineNumber(map, 1);
MarkerUtilities.setMessage(map, "HAZARD");
map.put(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
MarkerUtilities.createMarker(resource, map, IMarker.TEXT);
}
The code appeared not to work - but on closer inspection something is happening. There is now a 'clickable' area on the ruler, but no icon...
Before:
After:
Any ideas?
(I'm aware there's a similar question - but it was self-solved and as we are using different approaches and getting different responses I thought it was worth opening this one up.)
As far as I can see, you define a org.eclipse.core.resources.textmarker.
But I cannot find a org.eclipse.ui.ide.markerImageProviders with an image for the marker type. So I simply believe, there are no image for this type.
Try using a different type of marker type, define your own marker type or define your own image for the textmarker marker type (not recommended).