WTL. Class derived from CEdit. Parent window does not react for EN_CHANGE - wtl

I need to handle EN_CHANGED.
COMMAND_HANDLER_EX(0, EN_CHANGE, OnEdit)
It works when I am using CEdit.
But it does not work when I am using CMyEdit.
class CMyEdit : public CWindowImpl<CMyEdit, CEdit>
What do I have to do?

You have specified 0 rather than a control ID as the first parameter of the command_handler_ex macro

Related

DI - resolving instance using parameter (Prism using DryIoc)

I've been searching over the web how could I resolve instance using Prism DryIOC that uses parameter during runtime, but to luck yet.
For example, I have a class:
internal sealed class ItemInfoHelper : IItemInfoHelper
{
//ctor
public ItemInfoHelper(Item item) {...}
public string GetSomething() {...}
}
And in registering service I need to register it.
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.Register<IItemInfoHelper, ItemInfoHelper>();
}
If I do this, when I resolve it somewhere like:
var helperInstance = container.Resolve<IItemInfoHelper>();
it will be obviously resolved using empty Item (using default Item constructor). I have seen a lot of examples that register instances using some parameters that are known at compile time. But the case is that I would like to resolve instance being initialized dynamically using Item that would be a different one in different places (i.e. known at runtime only).
Is there a way to register/resolve it using such behavior if I use Prism + DryIoc?
Thanks in advance.
The simplest type-safe way to do so is to resolve the function of item:
var getHelperInstance = container.Resolve<Func<Item, IItemInfoHelper>>();
var helperInstance = getHelperInstance(myItem);

Xamarin Dependency Injection fails - crash while trying to get platform specific implementation

I've got a Xamarin Forms interface that defines a Bluetooth controller. I'm following the usual technique when trying to create an Android specific implementation of this (I will also do an iOS one when I get this working).
I define my interface as follows :
namespace ArduinoRobotController.Models
{
public interface BluetoothControllerInterface
{
List<string> GetPairedDevices();
..
Then I have my platform specific implementation like this :
[assembly: Xamarin.Forms.Dependency(typeof(BluetoothControllerInterface))]
namespace ArduinoRobotController.Droid.Implementations
{
public class BluetoothController : BluetoothControllerInterface
{
..
Then finally back in one of my view models, I have this code to get the platform specific instance I need :
BluetoothControllerInterface bt = Xamarin.Forms.DependencyService.Get<BluetoothControllerInterface>();
It builds and runs, but crashes on the line above. The error states :
System.MissingMethodException: Default constructor not found for type ArduinoRobotController.Models.BluetoothControllerInterface at SystemRuntimeType.CreateInstanceMono
.. etc.
I've tried lots of different ways around doing this, including calling to register the implementation in normal code rather than as [assembly etc. Any help on this really appreciated.
your registration needs to point to the concrete class, not the interface
[assembly: Xamarin.Forms.Dependency(typeof(BluetoothController))]

How to set autocomplete="off" in vaadin

Is it possible to set HTML5 attribute autocomplete="off" on TextField in Vaadin 7?
I've searched but found no way to set attributes on text fields or just hint browser to disable native autocompletion on input fields in some other way in vaadin.
I think the only way if you use javascript:
TextField tf = new TextField();
tf.addStyleName("xyz");
JavaScript.getCurrent().execute(
"document.getElementsByClassName('xyz')[0].setAttribute('autocomplete', 'off')");
Extend the TextField...
package com.example;
import com.vaadin.ui.TextField;
public class MyTextField extends TextField {
// do other customization here as needed
}
...and - what's the key point here - its client-side Connector
package com.example.client;
import com.vaadin.client.ui.VTextField;
import com.vaadin.client.ui.textfield.TextFieldConnector;
import com.vaadin.shared.ui.Connect;
#Connect(com.example.MyTextField.class)
public class MyTextFieldConnector extends TextFieldConnector {
#Override
public VTextField getWidget() {
VTextField vTextField = super.getWidget();
vTextField.getElement().setAttribute("autocomplete","off");
return vTextField;
}
}
Don't forget to recompile the widget set.
If you use the Viritin add-on, you can now use the HtmlElementPropertySetter class to wrap your TextField component and use that to set the "autocomplete" element property to "off". You could also use the MTextField component that comes with Viritin and just create it as follows:
MTextField username = new MTextField("Username")
.withAutocompleteOff();
This is an extension to #Wojciech Marciniak's answer. His approach worked for me, but I want to note a couple or three modifications I had to do in order for it to work as of 2017/11/28.
1) autocomplete="off" don't seem to work anymore nowadays; at least not on Chrome. Instead, you can use autocomplete="new-password", which works on Chrome 62.0.3202.94 windows 64 bits. I also noticed some inconsistent behaviour with this attribute, as NOT always works - sometimes a list with choices for passwords will show up on the component (specially until you refresh a couple of times, etc.).
2a) Instead of extending the component, you may want to overwrite it by creating the com.vaadin.client.ui.(component)field package in your project, then put the modified (component)FieldConnector.java file in it (in my case I was modifying PasswordField) in case you want all your instances of this component to not remember passwords. The final class source should look like this:
package com.vaadin.client.ui.passwordfield;
import com.vaadin.client.ui.VPasswordField;
import com.vaadin.client.ui.textfield.TextFieldConnector;
import com.vaadin.shared.ui.Connect;
import com.vaadin.ui.PasswordField;
#Connect(PasswordField.class)
public class PasswordFieldConnector extends TextFieldConnector {
#Override
public VPasswordField getWidget() {
VPasswordField vTextField = (VPasswordField) super.getWidget();
vTextField.getElement().setAttribute("autocomplete","new-password");
return vTextField;
}
}
So this way you don't need any other class extending TextField (or PasswordField).
2b) If you want to allow some fields to remember passwords and other that don't, you can extend the component and use your preferred component accordingly. You can keep your connector class as in 2a) but remember to name it something like CustomPasswordFieldConnector, and it should also #Connect with that CustomPasswordField.class, put that class wherever it fits in your project and remember to add the proper import for it in the connector in case it's needed. This class is just a dummy one - you can leave its contents empty in case you don't need any extra functionality (but remember it should extend the proper (component)Field; PasswordField in the example).

How to start another Activity with android-annotation?

I'm just trying to use android-annotation. When I start another Activity, an empty activity showed up.
I check this to find that the #EActivity generate the subclass of XXActivity named XXActivity_. So I try to code
mIntent = new Intent(this, XXActivity_.class);
But eclipse shows error that XXActivity_ cannot be resolved to a type. I don't know when the XX_ is generated.
I have add the jar, declare the XX_ in the AndroidManifest.xml. How to make eclipse generate the XX_ class?
you could start activity using annotations like this
first you should write your activities on the manifest file with '_' after that you have two activities you want to go from one to another you could use this :
CarDetailActivity_.intent(CarSaleListActivity.this).start();
with this you will go the CarDetailActivity on the other hand if you want to pass message to the other activity you will use this
CarDetailActivity_.intent(CarSaleListActivity.this).myMessage("arrived with android annotations").start();
and in this case you should define this on the CarDetailActivity
#Extra
String myMessage;
and you could use this message on CarDetailActivity like this on
#AfterViews
public void showMessage(){
Toast.makeText(this,myMessage,Toast.LENGTH_SHORT).show();
}
Note : CarDetailActivity should be #EActivity to make this work
Blockquote

Monodroid binding change variable name

I try to bind BugSense 3.0.5 to MonoDroid. I create a new Java Binding Library project, add the bugsense3.0.5.jar to the Jars-folder. I build it, and get the following error:
'Crash': member names cannot be the same as their enclosing type
The auto generate code:
[global::Android.Runtime.Register ("com/bugsense/trace/models/Crash", DoNotGenerateAcw=true)]
public partial class Crash : global::Java.Lang.Object, global::Java.IO.ISerializable {
[Register ("CRASH")]
public const int Crash = (int) 1;
So I need to rename the global variable "Crash" in the Metadata.xml- but how do I do that?
I have try:
<attr path="/api/package[#name='com.bugsense.trace.models']/class[#name='Crash']/field[#name='Crash']" name="managedName">mCrash</attr>
But it fails: matched no nodes
Fixed it renaming the class instead
<attr path="/api/package[#name='com.bugsense.trace.models']/class[#name='Crash']]" name="managedName">Crashed</attr>
You should always look for original fields name in java.
As i know it is lowerCamelCase. And it is probably hidden into setter/getter so you should search for /method[#name='getCrash']

Resources