react-native icon indicating copy to clipboard operation
react-native copied to clipboard

TextInput multiline support

Open fdecampredon opened this issue 11 years ago • 10 comments

The multiline option does not work at all in my ios simulator (in fact the input is not editable with multiline).

The doc says :

The multiline prop is not supported in all release

Could we have more of information ? :)

fdecampredon avatar Mar 26 '15 23:03 fdecampredon

Yeah sorry, we haven't ported that functionality to open source yet.

On Mar 26, 2015, at 4:38 PM, François de Campredon [email protected] wrote:

The multiline options does not work at all in my ios simulator (in fact the input is not editable with multiline={true}).

The doc says :

The multiline prop is not supported in all release Could we have more of information ? :)

— Reply to this email directly or view it on GitHub.

sahrens avatar Mar 27 '15 07:03 sahrens

@sahrens Do you have an approximate time frame for when we can expect this feature? And thanks for all the hard work you and the React Native team have already done on this!

minizatic avatar Mar 28 '15 17:03 minizatic

+1

boyswan avatar Apr 03 '15 19:04 boyswan

Thanks for +1-ing issues like this, helps us prioritize. Unfortunately there is no estimate yet...

On Apr 3, 2015, at 12:03 PM, Jack Boyce [email protected] wrote:

+1

— Reply to this email directly or view it on GitHub.

sahrens avatar Apr 03 '15 19:04 sahrens

+1 as well :) I got a version with minimal functionality working on my side, by creating a custom view/manager, might be useful in the interim.

#import "RCTViewManager.h"
#import "RCTBridge.h"
#import "RCTEventDispatcher.h"
#import "UIView+React.h"

@class RCTEventDispatcher;

@interface RCTUITextView : UITextView<UITextViewDelegate>
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
@end

@implementation RCTUITextView
RCTEventDispatcher *_eventDispatcher;

- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher
{
  if ((self = [super initWithFrame:CGRectZero])) {
    _eventDispatcher = eventDispatcher;
    [self setDelegate:self];
  }
  return self;
}

- (void)textViewDidEndEditing:(UITextView *)textView
{
  [_eventDispatcher sendTextEventWithType:RCTTextEventTypeEnd
                                 reactTag:self.reactTag
                                     text:self.text];
}

- (void)textViewDidChange:(UITextView *)textView
{
  [_eventDispatcher sendTextEventWithType:RCTTextEventTypeChange
                                 reactTag:self.reactTag
                                     text:self.text];
}
@end

@interface UITextViewManager : RCTViewManager

@end

@implementation UITextViewManager

- (UIView *)view
{
  return [[RCTUITextView alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
}

RCT_EXPORT_VIEW_PROPERTY(text, NSString)

@end

UITextView.js

'use strict'

var createReactIOSNativeComponentClass = require('createReactIOSNativeComponentClass');

module.exports = createReactIOSNativeComponentClass({
  validAttributes: { text: true },
  uiViewClassName: 'UITextView',
});
  <UITextView onChange={(de) => console.log(de.nativeEvent.text)} onEndEditing={(de) => console.log("end: ",de.nativeEvent.text)}/>

mattds avatar Apr 03 '15 22:04 mattds

+1

cloudify avatar Apr 14 '15 15:04 cloudify

+1

lukasredev avatar Apr 15 '15 12:04 lukasredev

:+1:

ziyadparekh avatar Apr 16 '15 13:04 ziyadparekh

+1

aaronksaunders avatar Apr 25 '15 23:04 aaronksaunders

This is now being tracked in #991 - mostly done, just fixing an existing TextInput bug that I encountered along the way.

brentvatne avatar Apr 26 '15 00:04 brentvatne