I'm trying to derive a native class compiled from iCarousel native library ( used the LinkWith method described in this example ).
When using the generated binding everything works perfectly:
iCarousel carousel = new iCarousel( new RectangleF(0, 0, 300, 300) );
But when trying to create this derived class:
public class Carousel2 : iCarousel
{
public Carousel2( RectangleF rect ) : base(rect)
{
Console.WriteLine("do something");
}
}
and using it like this:
Carousel2 carousel = new Carousel2( new RectangleF(0, 0, 300, 300) );
It compiles but it just stops working, with no error. Is it something I'm missing?
UPDATE: I've put the objective-c header and the ApiDefinition.cs source code here:
http://dantes-andreea.blogspot.com/2012/02/icarousel-monotouch-binding-code.html
I think you need to pass -e to btouch when generating the bindings, otherwise they will not be subclassable.
By default btouch does not generate subclassable types because they're a little bit slower.
Update
I was wrong, the -e switch must not be passed to btouch to generate subclassable bindings. Unfortunately this switch is passed unconditionally. A bug report has been filed.
You can probably work around it by manually running the btouch command after MonoDevelop has built the project (you build the bindings project, c&p the btouch command line and remove the -e switch). Then you'll also have to run any subsequent steps manually too.
Related
I'm writing a intellij plugin to let people choose a class, I find the code the move method in intellij open source code.
The move method picture is like this which will show all project class.
but when I using the following code the pic is this
There is no recommend class, after I type some text, still nothing.
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myProject).createWithInnerClassesScopeChooser(
"choose serviceClass", GlobalSearchScope.projectScope(myProject), new ClassFilter() {
public boolean isAccepted(PsiClass aClass) {
return aClass.getParent() instanceof PsiFile && !aClass.isInterface();
}
}, srcClass);
chooser.selectDirectory(pojoClass.getContainingFile().getContainingDirectory());
chooser.showDialog();
That seems to be a bug in the IDE, fixed in the upcoming 2017.2 release.
I’m using JavaFX 8 and JDK 1.8.0_77 in IntelliJ with SceneBuilder. I created a basic pixel editor app. I have two windows(stages). One is a 32x128 matrix of Circle Objects placed in a Grid Pane and the other is a Message Center in Main.
You can see the Message Center window at: https://virtualartsite.wordpress.com/message-center/
I want to save messages using the Message Center app and scroll them on an RGB LED matrix that’s also 32x128. I save the messages in ArrayList<> of Message Objects and I write the ArrayList’s Message’s to a serialized file. I write the file calling writeObjArrayList () and input the file calling readObjArrayList().
I am able to write and read the file successfully and .add all the Message objects to the ArrayList on start-up so the user can edit or delete any message from the viewMessages ComboBox. BUT so far, I can only do so if I use a button event to call readObjArrayList(). This is the problem.
I want to read the file “behind the scenes”, when the app starts. I want to automatically read the file when the program starts up; the user shouldn’t have to click on a button.
My best idea was to use the following code which compiles but doesn’t appear to execute any code:
public void windowEvents(WindowEvent event){
if(event.getSource() == viewMessages) readObjArrayList();
}
I thought a WindowEvent would be fired with windowEvents=#OnShow for the ComboBox, viewMessages(FX:ID).
Please advise.
Thanks for your help.
According to the javadoc, the WindowEvent is related to Window showing/hiding actions. As Node classes aren't Windows, installing a WindowEvent handler on it won't have any effect.
Since you are using SceneBuilder, I assume that you must have an FXML file that has a fx:controller class defined. In any controller class, you can add a non-arg initialize() method which will be called right after the FXML file has been processed.
public class YourController {
#FXML
ComboBox viewMessages;
public void initialize() {
readObjArrayList();
}
private void readObjArrayList() {
...
}
}
I am trying to convert an open source flyout menu from Objective-C to Xamarin. The current issue I have is that the Obj-C code creates a frame using CGRectInfinite. This does not appear to be available under MonoTouch, via the usual RectangleF class. Is there an alternative?
Similarly, there does not appear to be a CGRectIsInfinite equivalent in RectangleF. What, if any, is the alternative?
Add this using statement first:
using MonoTouch.CoreGraphics;
Then you can test it with this:
public static RectangleF GetInfinite()
{
var image = CIImage.EmptyImage;
if (image.Extent.IsInfinite ())
{
return image.Extent;
}
throw new Exception ("Unable to create infinite rect");
}
I want to create a simple eclipse plugin, which does: When you right click a java project, it will show a popup menu which has a item has label "N java files found in this project", where "N" is the file count.
I have an idea that I can update the label in "selectionChanged":
public class CountAction implements IObjectActionDelegate {
public void selectionChanged(IAction action, ISelection selection) {
action.setText(countJavaFiles());
}
}
But it doesn't work if I don't click that menu item, since the CountAction has not been loaded, that selectionChanged won't be invoked when you right-click on the project.
I have spent a lot of time on this, but not solved. Please help me.
An alternative to the article suggested by #kett_chup, is to use IElementUpdater. Simply
your handler must implement IElementUpdater
the handler.updateElement((UIElement element, Map parameters) must set the wanted text using element.setText("new text") - this new text will show up in menus and toolbars
whenever you need/want to update the command text use ICommandService.refreshElements(String commandId, Map filter) with your particular command ID - the global command service usually is just fine
The IElementUpdater interface can also be used to change the checked state - for commands with style=toggle - as well as the icons and the tool tip.
At last, I found a very easy way to implement this:
I don't need to change my code(the sample code in question), but I need to add a small startup class:
import org.eclipse.ui.IStartup;
public class MyStartUp implements IStartup {
#Override
public void earlyStartup() {
// Initial the action
new CountAction();
}
}
And add following to plugin.xml:
<extension
point="org.eclipse.ui.startup">
<startup
class="myplugin.MyStartUp">
</startup>
This MyStartUp will load an instance of that action at startup, then selectionChanged will be invoked each time when I right-click the projects or files.
I'm doing an experiment with wxWebConnect test application, incorporating the xpcom tutorial at "http://nerdlife.net/building-a-c-xpcom-component-in-windows/"
I adapt MyComponent class as necessary to compile together with testapp.exe (not as separate dll), and on MyApp::OnInit I have the following lines:
ns_smartptr<nsIComponentRegistrar> comp_reg;
res = NS_GetComponentRegistrar(&comp_reg.p);
if (NS_FAILED(res))
return false;
ns_smartptr<nsIFactory> prompt_factory;
CreateMyComponentFactory(&prompt_factory.p);
nsCID prompt_cid = MYCOMPONENT_CID;
res = comp_reg->RegisterFactory(prompt_cid,
"MyComponent",
"#mozilla.org/mycomp;1",
prompt_factory);
Those lines are copied from GeckoEngine::Init(), using the same mechanism to register PromptService, etc. The code compiles well and testapp.exe is running as expected.
I put javascript test as below :
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
const cid = "#mozilla.org/mycomp;1";
obj = Components.classes[cid].createInstance();
alert(typeof obj);
// bind the instance we just created to our interface
alert(Components.interfaces.nsIMyComponent);
obj = obj.QueryInterface(Components.interfaces.nsIMyComponent);
} catch (err) {
alert(err);
return;
}
and get the following exception:
Could not convert JavaScript argument arg 0 [nsISupport.QueryInterface]
The first alert says "object", so the line
Components.classes[cid].createInstance()
is returning the created instance.
The second alert says "undefined", so the interface nsIMyComponent is not recognized by XULRunner.
How to dynamically registering nsIMyComponent interface in wxWebConnect environment ?
Thx
I'm not sure what is happening here. The first thing I would check is that your component is scriptable (I assume it is, since the demo you copy from is). The next thing I would check is whether you can instantiate other, standard XULRunner components and get their interface (try something like "alert('Components.interfaces.nsIFile');" - at least in my version of wxWebConnect this shows an alert box with string "nsIFile".
Also, I think it would be worth checking the Error Console to make sure there are no errors or warnings reported. A magic string to do that (in Javascript) is:
window.open('chrome://global/content/console.xul', '', 'chrome,dialog=no,toolbar,resizable');