frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

(Harmony OS Next)Simplified Usage of Search Component

2•flfljh•3h ago
# Simplified Usage of Search Component

### 1. Basic Usage

- *Import and Creation*: In an ETS file, first import the Search component via `import { Search } from '@ohos.arkui.advanced.Search'`. Then create a Search instance in the component's `build` method:

     ```typescript
     Search({ value: this.searchText, placeholder: 'Search...' })
      .width('90%')
      .height(40)
      .onSubmit((value: string) => {
     // Handle search submission logic
       })
      .onChange((value: string) => {
     // Handle input change logic
       });
     ```
This sets the initial text (`value`), placeholder text, dimensions, and event listeners for `onSubmit` (search submission) and `onChange` (input changes).

### 2. Property Configuration

- *Search Button Style*: Customize the search button using `searchButton`:

```typescript .searchButton('SEARCH', { fontSize: '16fp', fontColor: '#ff3f97e9' }) ```

- *Placeholder Styling*: `placeholderColor` sets placeholder text color `placeholderFont` sets placeholder font style:

```typescript .placeholderColor(Color.Grey) .placeholderFont({ size: 14, weight: 400 }) ```

- *Text Styling*: `textFont` customizes input text appearance - *Alignment*: `textAlign` (API 9+) sets text alignment (`TextAlign.Start` default) - *Icon Styling*: `searchIcon` (API 10+) customizes search icon `cancelButton` customizes clear button - *Text Copying*: `copyOption` (API 9+) enables text copying (default: `CopyOptions.LocalDevice`) - *Additional Properties*: `fontColor` - Input text color `caretStyle` - Cursor appearance `enableKeyboardOnFocus` - Auto-open keyboard on focus

### 3. Event Handling

- *Search Submission*: `onSubmit` triggers when: • Search icon clicked • Search button pressed • Keyboard search key pressed - *Input Changes*: `onChange` triggers during text input - *Text Operations*: `onCopy` - Copy operations `onCut` - Cut operations `onPaste` - Paste operations `onTextSelectionChange` - Text selection changes `onContentScroll` - Content scrolling

### 4. Controller Usage

- *Controller Creation*: `controller: SearchController = new SearchController()` - *Cursor Control*: `this.controller.caretPosition(1)` positions cursor after first character - *Exit Edit Mode*: `this.controller.stopEditing()` closes keyboard (custom keyboard scenarios)

### 5. Custom Keyboards

1. Create custom keyboard component: ```typescript @Builder CustomKeyboardBuilder() { Column() { // Custom keyboard layout and logic } } ``` 2. Bind to Search component: ```typescript Search({ controller: this.controller, value: this.inputValue}) .customKeyboard(this.CustomKeyboardBuilder()) ```

### 6. Input Types & Restrictions

- *Input Types* (API 11+): `SearchType.Normal` - Default text input `SearchType.NUMBER` - Numeric only `SearchType.PHONE_NUMBER` - Phone number format `SearchType.EMAIL` - Email format - *Length Limit*: `maxLength` restricts character count

### 7. Advanced Features

- *Text Styling* (API 12+): `decoration` - Text underline styling `textIndent` - First-line indentation `letterSpacing` - Character spacing `lineHeight` - Line height `selectedBackgroundColor` - Selection highlight color - *Input Preview*: `enablePreviewText` enables/disables input preview (default enabled) - *Input Filtering*: `inputFilter` uses regex to restrict allowed characters

By combining these features, developers can create powerful search components tailored to specific application requirements. Consider API version support when implementing features, and leverage new capabilities to optimize search functionality.

Show HN: Wtmf.ai Your AI companion that understands

https://www.wtmf.ai
1•ishqdehlvi•2m ago•0 comments

Ask HN: Using AI daily but not seeing productivity gains – is it just me?

3•grandimam•8m ago•2 comments

Iran threatened attacks by sleeper cells inside U.S. if it was attacked

https://www.msnbc.com/msnbc/watch/iran-threatened-attacks-by-sleeper-cells-inside-u-s-if-it-was-attacked-242059333587
1•EvgeniyZh•13m ago•0 comments

RAG is the way about retrieval, agent, and grounding truth

https://psiace.me/posts/rag-is-the-way/
1•repsiace•24m ago•0 comments

RAG in Coding Agents: Making Smarter Programming Assistants

https://psiace.me/posts/rag-in-coding-agent/
1•repsiace•26m ago•0 comments

Another What to Watch App

https://what2watch2.vercel.app/
1•memonkey•35m ago•1 comments

Faking Relativity

https://tiffnix.com/faking-relativity
1•gsky•36m ago•0 comments

Show HN: SX – Transfer files from within SSH sessions without reconnecting

https://github.com/Memphizzz/SX
1•memphizzz•38m ago•0 comments

Dropping the First Atomic Bombs

https://www.theguardian.com/world/2025/jun/22/atomic-bomb-hiroshima-nagasaki-author-stephen-walker
1•rippeltippel•40m ago•0 comments

Are we overfitting our code to trends instead of problems?

1•fewbenefit•41m ago•1 comments

Nano-Vllm: lightweight vLLM implementation built from scratch

https://github.com/GeeeekExplorer/nano-vllm
3•simonpure•42m ago•0 comments

Are we overfitting our code to trends instead of problems?

1•fewbenefit•45m ago•0 comments

Framework for Skill Learning

4•michaelshoe•53m ago•0 comments

Openmovement – Watchmaking 2.0

https://openmovement.org/
1•pabs3•1h ago•0 comments

FedEx founder Fred Smith dies at 80

https://apnews.com/article/fred-smith-fedex-founder-died-645c93a192744e1ab8817ffb894ead01
1•keepamovin•1h ago•0 comments

Show HN: A zero-config HTML report plugin for Pytest (single file, CI-friendly)

1•nefaurio•1h ago•0 comments

Product Management: The Good, the Hard, and How to Know If It's Right for You

https://elezea.com/2025/06/product-management-the-good-the-hard-and-how-to-know-if-its-right-for-you/
3•mooreds•1h ago•0 comments

Implicit is better than explicit

https://sophiabits.com/blog/implicit-is-better-than-explicit
3•todsacerdoti•1h ago•0 comments

What I learned recording hours of teens on their phones

https://www.theguardian.com/film/2025/jun/22/lauren-greenfield-social-studies-documentary-film-adolescence-teenagers-phones
3•sandebert•1h ago•0 comments

Compressing for the Browser in Go

https://blog.kowalczyk.info/a-5hum/compressing-for-the-browser-in-go.html
2•todsacerdoti•1h ago•0 comments

I built an app to backup Live Photos from iPhone to external hard drives

2•xmasterdev•1h ago•0 comments

Unlocking Efficiency: Asus IoT Drives Smart Factory Development Through AI

https://iot.asus.com/resources/casestudies/drive-smart-factory-development-through-ai/
1•teleforce•1h ago•0 comments

Vera Rubin Scientists Reveal Telescope's First Images

https://www.nytimes.com/2025/06/23/science/vera-rubin-scientists-reveal-telescopes-first-images.html
3•donohoe•1h ago•0 comments

Converting Sourcemaps to Original JavaScript/TypeScript Sourcecode

https://yasoob.me/posts/converting-sourcemap-to-original-sourcecode/
2•yasoob•1h ago•0 comments

The Sad Case of the Youngest-Ever Alzheimer's Diagnosis

https://www.sciencealert.com/the-sad-case-of-the-worlds-youngest-ever-alzheimers-diagnosis
8•breitling•1h ago•1 comments

LeetCode for System Design

https://leetsys.dev
32•rbajp•1h ago•13 comments

Open Source AI Presentation Generator

https://github.com/AmNotAGoose/PPTX-Presentation-Generator
2•jonjlee•1h ago•0 comments

What's inside OpenAI Codex CLI: It’s simpler than I thought

https://medium.com/@dolevietthang/whats-inside-openai-codex-63a43ea94a48
2•vietthangif•1h ago•0 comments

Trump can pull the plug on the internet, and Europe can't do anything about it

https://www.politico.eu/article/donald-trump-eu-internet-europe-us-trade-war-data-cyber/
6•baobun•1h ago•2 comments

My go to tech stack for hosting Web Apps (including vibe coded variety)

https://musings-mr.net/post/my-go-to-tech-stack-for-web-apps
3•mrkiouak•1h ago•2 comments