-
-
Save kirillp/4cc967c813194d087ff0ec237a64c43f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package delightex.moe.nativecontrols; | |
import apple.coregraphics.struct.CGRect; | |
import apple.uikit.UITextField; | |
import apple.uikit.struct.UIEdgeInsets; | |
import delightex.graphics.moe.util.MoeUtils; | |
import delightex.tools.Logger; | |
import org.moe.natj.general.Pointer; | |
import org.moe.natj.general.ann.ByValue; | |
import org.moe.natj.general.ann.Runtime; | |
import org.moe.natj.objc.ObjCRuntime; | |
import org.moe.natj.objc.ann.ObjCClassName; | |
import org.moe.natj.objc.ann.Selector; | |
@Runtime(ObjCRuntime.class) | |
@ObjCClassName("CustomTextField") | |
class CustomTextField extends UITextField { | |
private UIEdgeInsets myPaddingInsets; | |
protected CustomTextField(Pointer peer) { | |
super(peer); | |
Logger.log("CustomTextField.ctor"); | |
} | |
@Selector("alloc") | |
public static native CustomTextField alloc(); | |
@Selector("init") | |
public native CustomTextField init(); | |
@Override | |
public CGRect editingRectForBounds(@ByValue CGRect cgRect) { | |
return textRectForBounds(cgRect); | |
} | |
@Override | |
public CGRect textRectForBounds(@ByValue CGRect cgRect) { | |
return myPaddingInsets != null ? MoeUtils.inset(cgRect, myPaddingInsets) : cgRect; | |
} | |
void setPadding(double top, double right, double bottom, double left) { | |
myPaddingInsets = new UIEdgeInsets(top, left, bottom, right); | |
setNeedsLayout(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment